ulisesbocchio / jasypt-spring-boot

Jasypt integration for Spring boot
MIT License
2.87k stars 514 forks source link

nacos password decryption in application.yml #385

Closed sochina-heart closed 6 months ago

sochina-heart commented 6 months ago

My project uses 3.0.5 jasypt-spring-boot-starter and spring cloud alibaba 2022.0.0.0. After encrypting the nacos password, the nacos configuration cannot be obtained when the project is started. Now the nacos configuration seems to be loaded earlier than jasypt.

sochina-heart commented 6 months ago

I just solved this problem, I introduced dependency `

org.springframework.cloud
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>4.1.0</version>

The latest springcloud does not seem to support the bootstrap.yml configuration file, so you need to introduce this maven dependency. spring: config: import:` If this configuration is in the same configuration file as the nacos configuration information, the nacos configuration file will be given priority when the project is started. At this time, jasypt has not yet started to decrypt. I used the bootstrap.yml configuration file to have a higher priority than application.yml. I put the nacos related configuration into the bootstrap.yml configuration file, and the configuration of the external configuration file introduced by spring into applcation.yml. This problem was successfully solved. At this time, the project At startup, the jasypt configuration file encryption will be loaded first, and then the nacos external configuration will be introduced.

sochina-heart commented 6 months ago

My current configuration is as follows: a b

zengyr49 commented 3 months ago

i guess you were using spring boot with version lower than 2.4. In spring boot version higher than 2.4, bootstrap file is not supported. Did you find any other solution?

sochina-heart commented 3 months ago

�i guess you were using spring boot with version lower than 2.4. In spring boot version higher than 2.4, bootstrap file is not supported. Did you find any other solution?

The springboot version I used at the time was 3.0.x, but I forgot the specific version. I didn't find any other solution at the time