Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

通过starter集成后bootstrap里的配置会被清除 #256

Closed
iwfun opened this issue Jan 21, 2021 · 7 comments
Closed

通过starter集成后bootstrap里的配置会被清除 #256

iwfun opened this issue Jan 21, 2021 · 7 comments

Comments

@iwfun
Copy link

iwfun commented Jan 21, 2021

jasypt-spring-boot-starter
version 3.0.3

bootstrap.yml

spring.application:
  name: iam-auth

logback.xml
<springProperty scope="context" name="APPLICATION" source="spring.application.name"/>

spring.application.name 被清除了

iam-auth | 2021-01-21 21:15:55.601 |  INFO | main -> c.u.j.EncryptablePropertySourceConverter#makeEncryptable:56 | Converting PropertySource applicationConfig: [classpath:/bootstrap.yml] [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper
iam-auth | 2021-01-21 21:15:55.646 |  INFO | main -> c.u.j.f.DefaultLazyPropertyFilter#lambda$null$2:31 | Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter
iam-auth | 2021-01-21 21:15:55.705 |  INFO | main -> c.u.j.r.DefaultLazyPropertyResolver#lambda$null$2:35 | Property Resolver custom Bean not found with name 'encryptablePropertyResolver'. Initializing Default Property Resolver
iam-auth | 2021-01-21 21:15:55.706 |  INFO | main -> c.u.j.d.DefaultLazyPropertyDetector#lambda$null$2:35 | Property Detector custom Bean not found with name 'encryptablePropertyDetector'. Initializing Default Property Detector

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.7.RELEASE)

APPLICATION_IS_UNDEFINED | 2021-01-21 21:15:55.769 |  INFO | main -> c.i.d.DemoApplication#logStartupProfileInfo:655 | The following profiles are active: dev
APPLICATION_IS_UNDEFINED | 2021-01-21 21:15:56.160 |  INFO | main -> o.s.c.c.s.GenericScope#setSerializationId:295 | BeanFactory id=b48e4233-42c7-336c-a0c0-e6bbcf47b5e7
APPLICATION_IS_UNDEFINED | 2021-01-21 21:15:56.172 |  INFO | main -> c.u.j.c.EnableEncryptablePropertiesBeanFactoryPostProcessor#postProcessBeanFactory:39 | Post-processing PropertySource instances
@iwfun
Copy link
Author

iwfun commented Jan 21, 2021

这是复现的demo

https://github.com/iwfun/jasypt-demo

@yakamy
Copy link

yakamy commented Sep 15, 2021

我这边也遇到这个问题了,当jasypt和springcloud一起使用时,bootstrap的配置会失效。

追踪代码发现,spring在启动bootstrap容器后,当把bootstrap容器的environment合并到子容器时,只同步了OriginTrackedMapPropertySource类型 BootstrapApplicationListener

此时所有的PropertySource都已经被包装为EncryptablePropertySourceWrapper,所以会导致bootstrap的配置不会合并到子容器。

@sondertara
Copy link

最简单的办法就是 在bootstrap中不到引入profiles.active和profiles.include,通过Jvm参数指定spring.profiles.active=xxx来让application-xxx文件生效,在application中使用include

@dcqyzb
Copy link

dcqyzb commented Apr 18, 2022

+1 目前只能配置jasypt.encryptor.bootstrap为false让jasypt对bootstrap.yml不做处理来规避这个问题了

这样对正常application配置文件里面的内容动态加解密没有影响,只会对bootstrap.yml中的加密配置有影响是吗

@1em0n9527
Copy link

1em0n9527 commented Sep 30, 2022

也碰到了这个问题, bootstrap.yml 内容不能继承到 application.yml , 如果加上 排除bootstrap参数, 又会导致 bootstrap 的关于配置中心的加密参数失效, 这个配置中心参数又必须得放到 bootstrap, 死循环了这是.

English version:
I have the same problem, that bootstrap.yml content is isolation with application.yml, if add

jasypt.encryptor.bootstrap=true

the ENC(xxx) in bootstrap is invalid, which is about config center value,
oh...

@sondertara
Copy link

也碰到了这个问题, bootstrap.yml 内容不能继承到 application.yml , 如果加上 排除bootstrap参数, 又会导致 bootstrap 的关于配置中心的加密参数失效, 这个配置中心参数又必须得放到 bootstrap, 死循环了这是.

English version: I have the same problem, that bootstrap.yml content is isolation with application.yml, if add

jasypt.encryptor.bootstrap=true

the ENC(xxx) in bootstrap is invalid, which is about config center value, oh...

bootstrap中不要使用profiles.active和profiles.include这类引入application的配置,通过启动参数指定运行环境就可以规避这个问题,在低于spring-boot 2.4经过生产验证

@luob1024
Copy link

luob1024 commented Nov 8, 2023

也碰到了这个问题, bootstrap.yml 内容不能继承到 application.yml , 如果加上 排除bootstrap参数, 又会导致 bootstrap 的关于配置中心的加密参数失效, 这个配置中心参数又必须得放到 bootstrap, 死循环了这是.

这个现象是应为jasypt引入之后产生了两次logback初始化,一次是拿到了,一次没拿到。
可以通过,在bootstrap中再指定一次日志默认文件,相当于让logback再初始化(三次初始化,获取到-没获取到-获取到),可以从表象中解决。#logging.config=classpath:logback-spring.xml。
也可以配置jasypt.encryptor.bootstrap=true,让apllication正确的合并bootstrap的配置文件,两次初始化都可以获取到name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants