Skip to content

Commit 37d7e2c

Browse files
committed
sunnychan
1 parent fdfd13c commit 37d7e2c

File tree

11 files changed

+143
-3
lines changed

11 files changed

+143
-3
lines changed

.idea/compiler.xml

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@
4444
<module>spring-event</module>
4545
<module>spring-data</module>
4646
<module>spring-bean</module>
47+
<module>spring-cookbook</module>
4748
</modules>
4849
</project>

spring-bean/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
<dependency>
3333
<groupId>org.springframework</groupId>
3434
<artifactId>spring-context</artifactId>
35-
<scope>test</scope>
3635
</dependency>
3736
</dependencies>
3837

spring-bean/src/main/java/me/sunny/demo/spring/bean/lifecycle/MyBeanPostProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
*/
99
public class MyBeanPostProcessor implements BeanPostProcessor {
10+
1011
@Override
1112
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
1213
System.out.println("post Process Before Initialization is invoked");

spring-cookbook/pom.xml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>spring-demo</artifactId>
7+
<groupId>me.sunny.demo.spring</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<groupId>me.sunny.demo.spring.cookbook</groupId>
13+
<artifactId>spring-cookbook</artifactId>
14+
15+
<name>spring-cookbook</name>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.springframework</groupId>
20+
<artifactId>spring-beans</artifactId>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.springframework</groupId>
24+
<artifactId>spring-core</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.springframework</groupId>
28+
<artifactId>spring-test</artifactId>
29+
<scope>test</scope>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.springframework</groupId>
33+
<artifactId>spring-context</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-web</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>com.alibaba</groupId>
41+
<artifactId>fastjson</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>junit</groupId>
45+
<artifactId>junit</artifactId>
46+
</dependency>
47+
</dependencies>
48+
49+
</project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4" />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package me.sunny.demo.spring.cookbook;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
5+
6+
</beans>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package me.sunny.demo.spring.cookbook;
2+
3+
import java.util.HashMap;
4+
import java.util.Iterator;
5+
import java.util.Map;
6+
7+
import com.alibaba.fastjson.JSON;
8+
9+
import org.junit.Test;
10+
import org.junit.runner.RunWith;
11+
import org.springframework.beans.factory.annotation.Autowired;
12+
import org.springframework.core.env.Environment;
13+
import org.springframework.core.env.PropertySource;
14+
import org.springframework.test.context.ContextConfiguration;
15+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
16+
import org.springframework.web.context.support.StandardServletEnvironment;
17+
18+
@RunWith(SpringJUnit4ClassRunner.class)
19+
@ContextConfiguration({"classpath:spring.xml"})
20+
public class TestSpringEnv {
21+
22+
@Autowired
23+
private Environment environment;
24+
25+
@Test
26+
public void testGetSpringEnv(){
27+
System.out.println(JSON.toJSONString(environment.getActiveProfiles()));
28+
System.out.println(JSON.toJSONString(environment.getDefaultProfiles()));
29+
}
30+
}

0 commit comments

Comments
 (0)