Spring Profile and Jasypt

Contents

What annotation do you use to quickly switch between different environments to load different configurations?

@Profile is used to quickly switch between different environments to load different configurations.

  • Add @Profile annotation to the configuration class.

      @Configuration
      @Profile("dev")
      public class DevConfig {
          // ...
          @Value("${spring.datasource.url}")
          private String url;
      }
    
  • Add spring.profiles.active in application.properties file.

      spring.profiles.active=dev
    

What is Jasypt?

Jasypt is a java library which allows the developer to perform encryption and decryption in Java application. Such as password, database connection strings, etc.

Contents