Added sample code for Spring events and Spring profiles.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package org.baeldung.profiles;
|
||||
|
||||
public interface DatasourceConfig {
|
||||
public void setup();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.baeldung.profiles;
|
||||
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Profile("dev")
|
||||
public class DevDatasourceConfig implements DatasourceConfig {
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
System.out.println("Setting up datasource for DEV environment. ");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.baeldung.profiles;
|
||||
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Profile("production")
|
||||
public class ProductionDatasourceConfig implements DatasourceConfig {
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
System.out.println("Setting up datasource for PRODUCTION environment. ");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.baeldung.profiles;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.profiles")
|
||||
public class SpringProfilesConfig {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user