Closed scemsjyd closed 4 years ago
Sorry I've fixed the jasypt/encrypt doc issue in https://github.com/ulisesbocchio/jasypt-spring-boot/pull/219. That looks like it has been merged now.
I'll take a look at this issue now.
@ulisesbocchio I believe this feature got removed in this commit: https://github.com/ulisesbocchio/jasypt-spring-boot/commit/641f345b81825025c11d366af618635ecd40d60d.
The getFullFilePath after that change is not environment aware: https://github.com/ulisesbocchio/jasypt-spring-boot/blob/641f345b81825025c11d366af618635ecd40d60d/jasypt-maven-plugin/src/main/java/com/ulisesbocchio/jasyptmavenplugin/mojo/AbstractFileJasyptMojo.java#L47-L62
Whereas before the change it was: https://github.com/ulisesbocchio/jasypt-spring-boot/blob/380126293532891349d138f2b6d16d02eed5d92b/jasypt-maven-plugin/src/main/java/com/ulisesbocchio/jasyptmavenplugin/mojo/AbstractJasyptMojo.java#L53-L82
If this was unintentional, let me know and I can open a PR to fix this. Otherwise, I can open a PR to fix the docs.
@rupert-madden-abbott I did remove that code in favor of using -Djasypt.plugin.path="file:src/main/test/application-dev.properties"
the -Dspring.profiles.active=dev
param is still valid for the loading of the spring config but it doesn't work as one would expect. In order for the maven plugin to pick up any spring configuration you still need to pass -Dspring.config.location=file:src/main/resources
since you're not running from target/classes
or a jar
file from which the default value (classpath:,classpath:/config,file:,file:config/
) would work
@ulisesbocchio oh dear I didn't think of that. That is going to be pretty surprising and will catch lots of people out who will expect that to "just work".
I suggest that the plugin adds "spring.config.location=file:src/main/resources" as a default property when building the Spring app which should then make the plugin work as expected. I'll raise a PR for your consideration.
sounds good @rupert-madden-abbott, good idea. For now I updated the readme with the examples passing spring.config.location
. That change should also automatically pick the right application-${profile}.yml/properties
for config.
In terms of the file to use to pick up the encrypt/decrypt properties, we can leave as is to be specified by jasypt.plugin.path
but IF omitted and we want to tie it to the spring config we should use the same mechanism. Basically let Spring decide which config file(s) are going to be used, and get the exact files used from the environment.
One way of doing that would be:
Also noticed the plugin's Application:
@SpringBootApplication
public class Application {
}
doesn't have @EnableEncryptableProperties
which will potentially only work on projects that use the starter jar.
Also noticed the plugin's Application:
@SpringBootApplication public class Application { }
doesn't have
@EnableEncryptableProperties
which will potentially only work on projects that use the starter jar.
The plugin depends on the starter so the starter will always be in the plugins classpath. Therefore, it will always work without @EnableEncryptableProperties
.
In terms of the file to use to pick up the encrypt/decrypt properties, we can leave as is to be specified by jasypt.plugin.path
I think this is probably the clearest and least confusing way to go.
@scemsjyd Okay so the README is indeed wrong. If you want to encrypt application-dev.properties, then you need to specify it as follows:
jasypt:encrypt -Djasypt.plugin.path=file:src/main/resources/application-dev.properties -Djasypt.encryptor.password=YOUR_PASSWORD
The above PR fixes the docs to remove the incorrect advice.
hi guys, Is the filepath in readme wrong?
encrypt:encrypt --> jasypt:encrypt
otherwise
output:
Why application.properties and not application-dev.properties ?