Skip to content

Commit ed001ff

Browse files
configuring Spring Profiles
1 parent e0c1faf commit ed001ff

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package guru.springframework.test.ds;
2+
3+
import org.springframework.context.annotation.Profile;
4+
import org.springframework.stereotype.Component;
5+
6+
/**
7+
* Created by jt on 5/21/16.
8+
*/
9+
@Component
10+
@Profile("dev")
11+
public class DevDataSource implements FakeDataSource {
12+
@Override
13+
public String getConnectionInfo() {
14+
return "I'm the Development DataSource";
15+
}
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package guru.springframework.test.ds;
2+
3+
/**
4+
* Created by jt on 5/21/16.
5+
*/
6+
public interface FakeDataSource {
7+
8+
String getConnectionInfo();
9+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package guru.springframework.test.ds;
2+
3+
import org.springframework.context.annotation.Profile;
4+
import org.springframework.stereotype.Component;
5+
6+
/**
7+
* Created by jt on 5/21/16.
8+
*/
9+
@Component
10+
@Profile("prod")
11+
public class ProdDataSource implements FakeDataSource {
12+
@Override
13+
public String getConnectionInfo() {
14+
return "I'm the Production Datasource";
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package guru.springframework.test.ds;
2+
3+
import org.springframework.context.annotation.Profile;
4+
import org.springframework.stereotype.Component;
5+
6+
/**
7+
* Created by jt on 5/21/16.
8+
*/
9+
@Component
10+
@Profile("qa")
11+
public class QADataSource implements FakeDataSource {
12+
13+
@Override
14+
public String getConnectionInfo() {
15+
return "I'm the QA Datasource";
16+
}
17+
}

0 commit comments

Comments
 (0)