Search code examples
jarpropertiesannotationsjasypt

How do i declare the Encryptable Property Source annotation from Jasypt for the application yaml outside of a jar file?


My code works if my application.yaml is inside my resource folder.

    @EncryptablePropertySource("application.yaml")
public class Application {     public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

But for my client it is needed the application.yaml is outside of the jar (in the same path of the .jar file)

if i try @EncryptablePropertySource("path:..\\application.yaml") or ("path:C\\users\\me\\application.yaml") it doesn't seem to work. same counts if i use ("file:application.yaml")

Any sugestions? thanks in advance

EDIT: it worked like this `@EncryptablePropertySource("file:\\\Users\me\application.yaml")

but i should have ("file:\\\..\application.yaml") or something like this because the client directory will be not the same as mine ofcourse`


Solution

  • Hi I did a workaround like this : let me know what you think.

    mainclass:

    @EncryptablePropertySource("file:\\\\\\${position}")
    public class Application {
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    

    application.yaml:

    position:  Users\me\application.yaml