File tree Expand file tree Collapse file tree 6 files changed +70
-30
lines changed Expand file tree Collapse file tree 6 files changed +70
-30
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <classpath >
3+ <classpathentry kind =" src" path =" src/test/java" output =" target/test-classes" including =" **/*.java" />
4+ <classpathentry kind =" src" path =" src/main/java" including =" **/*.java" />
5+ <classpathentry kind =" src" path =" src/main/resources" excluding =" **/*.java" />
6+ <classpathentry kind =" output" path =" target/classes" />
7+ <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER" />
8+ <classpathentry kind =" var" path =" M2_REPO/junit/junit/4.11/junit-4.11.jar" />
9+ <classpathentry kind =" var" path =" M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" />
10+ <classpathentry kind =" var" path =" M2_REPO/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE.jar" />
11+ <classpathentry kind =" var" path =" M2_REPO/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE.jar" />
12+ <classpathentry kind =" var" path =" M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar" />
13+ <classpathentry kind =" var" path =" M2_REPO/org/springframework/spring-beans/3.1.0.RELEASE/spring-beans-3.1.0.RELEASE.jar" />
14+ <classpathentry kind =" var" path =" M2_REPO/org/springframework/spring-context/3.1.0.RELEASE/spring-context-3.1.0.RELEASE.jar" />
15+ <classpathentry kind =" var" path =" M2_REPO/org/springframework/spring-aop/3.1.0.RELEASE/spring-aop-3.1.0.RELEASE.jar" />
16+ <classpathentry kind =" var" path =" M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" />
17+ <classpathentry kind =" var" path =" M2_REPO/org/springframework/spring-expression/3.1.0.RELEASE/spring-expression-3.1.0.RELEASE.jar" />
18+ <classpathentry kind =" var" path =" M2_REPO/org/springframework/spring-context-support/3.1.0.RELEASE/spring-context-support-3.1.0.RELEASE.jar" />
19+ <classpathentry kind =" var" path =" M2_REPO/cglib/cglib-nodep/2.2/cglib-nodep-2.2.jar" />
20+ </classpath >
Original file line number Diff line number Diff line change 11package com .hmkcode ;
22
3- import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
43import org .springframework .context .support .ClassPathXmlApplicationContext ;
5- import org .springframework .context .support .GenericXmlApplicationContext ;
6- import org .springframework .core .env .ConfigurableEnvironment ;
7-
8- import com .hmkcode .spring .SpringConfig ;
94import com .hmkcode .vo .Person ;
105
11-
126public class App
137{
148 public static void main ( String [] args )
159 {
16-
17- // ( 1 ) System.setProperty("spring.profiles.active", "development");
18- //ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spring-config-all.xml");
19-
20- // ( 2 )
21- /*ConfigurableEnvironment env = ctx.getEnvironment();
22- env.setActiveProfiles("development");
23- ctx.refresh(); */
24-
25- //( 3 )
26- /*GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
27- ConfigurableEnvironment env = ctx.getEnvironment();
28- env.setActiveProfiles("production");
29- ctx.load("spring-config-development.xml","spring-config-production.xml");
30- ctx.refresh();*/
3110
32- //( 4 ) combine
11+ System .setProperty ("spring.profiles.active" , "development" ); //or production
12+ ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext ("spring-config-all.xml" );
3313
34-
35- //( 5 )
36- AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext ();
37- ctx .getEnvironment ().setActiveProfiles ("development" );
38- ctx .register (SpringConfig .class );
39- ctx .refresh ();
4014 Person person = (Person )ctx .getBean ("person" );
41-
42-
4315 System .out .println ("Person: " +person );
4416 }
4517}
Original file line number Diff line number Diff line change 1+ package com .hmkcode .vo ;
2+
3+ public class Person {
4+
5+ private int id ;
6+ private String name ;
7+ public int getId () {
8+ return id ;
9+ }
10+ public void setId (int id ) {
11+ this .id = id ;
12+ }
13+ public String getName () {
14+ return name ;
15+ }
16+ public void setName (String name ) {
17+ this .name = name ;
18+ }
19+
20+ public String toString (){
21+ return "Id: " +id +" - Name: " +name ;
22+ }
23+ }
File renamed without changes.
Original file line number Diff line number Diff line change 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
5+ http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"
6+ profile=" development" >
7+
8+
9+ <bean id =" person" class =" com.hmkcode.vo.Person" >
10+ <property name =" id" value =" 1" />
11+ <property name =" name" value =" dev-person" />
12+ </bean >
13+ </beans >
Original file line number Diff line number Diff line change 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
5+ http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"
6+ profile=" production" >
7+
8+ <bean id =" person" class =" com.hmkcode.vo.Person" >
9+ <property name =" id" value =" 2" />
10+ <property name =" name" value =" pro-person" />
11+ </bean >
12+ </beans >
You can’t perform that action at this time.
0 commit comments