ulisesbocchio / jasypt-spring-boot

Jasypt integration for Spring boot
MIT License
2.91k stars 522 forks source link

使用jasypt时,allow-bean-definition-overriding被强制关闭 #332

Open xiaomizhou2 opened 2 years ago

xiaomizhou2 commented 2 years ago

Description:

The bean 'middleoffice-systemservice-fast.FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

ooo176 commented 1 year ago

how to solve it

ulisesbocchio commented 1 year ago

what's this about? that bean is not defined by the plugin... and in any case, allow-bean-definition-overriding is something you can control from your application

ooo176 commented 1 year ago

just like this issue, if this starter uses with spring cloud feign, then this error will appear https://github.com/ulisesbocchio/jasypt-spring-boot/issues/301

ulisesbocchio commented 1 year ago

I'm gonna need more information tho.... do you have a test project I can run?

zhajianjun commented 1 year ago

springboot启动类修改

hmkelntuh085 commented 6 months ago

I also encountered this situation.

wj15118940771 commented 5 months ago

在bootstrap.yml配置allow-bean-definition-overriding=true的属性不起作用 是有先后顺序的问题吗

mulzhang commented 3 months ago

why???????

walldong commented 3 months ago

import jasypt-spring-boot-starter will make bootstrap.yml useless. I add config with jasypt.encryptor.bootstrap: false in bootstrap.yml to solve this problem

mulzhang commented 3 months ago

@walldong 能排查出这个问题的原因吗?为什么会影响到

walldong commented 3 months ago

@walldong 能排查出这个问题的原因吗?为什么会影响到

Spring Cloud 的 Bootstrap 阶段负责加载 bootstrap.yml 文件,这一阶段会在主应用上下文初始化之前执行。Spring Cloud 在合并 bootstrap 环境变量到主上下文时,只会合并 OriginTrackedMapPropertySource 类型的 PropertySource,而 Jasypt 在处理加密属性时,会将 PropertySource 包装为 EncryptablePropertySourceWrapper,导致 bootstrap.yml 中的加密配置在合并时被忽略。 application.yml 由于加载优先级滞后,所有它的加载就不会受影响