Spring Profiles

Sample

@Component
@Profile("dev")
public class DevDatasourceConfig
@Component
@Profile("!dev")
public class DevDatasourceConfig
<beans profile="dev">
  <bean id="devDatasourceConfig"
    class="com.okdevtv.profiles.DevDatasourceConfig" />
</beans>
@Configuration
public class MyWebApplicationInitializer implements WebApplicationInitializer {

  @Override
  public void onStartup(ServletContext servletContext) throws ServletException {
    servletContext.setInitParameter("spring.profiles.active", "dev");
  }
}
@Autowired
private ConfigurableEnvironment env;
// ...
env.setActiveProfiles("someProfile");
-Dspring.profiles.active=dev
export spring_profiles_active=dev
@ActiveProfiles("dev")

related

ref

What Else?
inflearn react api server -50% 할인쿠폰: 15108-f2af1e086101 buy me a coffee