diff --git a/src/main/java/guru/springframework/DiDemoApplication.java b/src/main/java/guru/springframework/DiDemoApplication.java index 581c6c52..541fe9cf 100644 --- a/src/main/java/guru/springframework/DiDemoApplication.java +++ b/src/main/java/guru/springframework/DiDemoApplication.java @@ -2,6 +2,7 @@ import guru.springframework.controllers.MyController; import guru.springframework.examplebeans.FakeDataSource; +import guru.springframework.examplebeans.FakeJmsBroker; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; @@ -17,5 +18,8 @@ public static void main(String[] args) { FakeDataSource fakeDataSource = (FakeDataSource) ctx.getBean(FakeDataSource.class); System.out.println(fakeDataSource.getUser()); + + FakeJmsBroker fakeJmsBroker = (FakeJmsBroker) ctx.getBean(FakeJmsBroker.class); + System.out.println(fakeJmsBroker.getUsername()); } } diff --git a/src/main/java/guru/springframework/config/PropertyConfig.java b/src/main/java/guru/springframework/config/PropertyConfig.java index dec2094b..a9c8794d 100644 --- a/src/main/java/guru/springframework/config/PropertyConfig.java +++ b/src/main/java/guru/springframework/config/PropertyConfig.java @@ -1,6 +1,7 @@ package guru.springframework.config; import guru.springframework.examplebeans.FakeDataSource; +import guru.springframework.examplebeans.FakeJmsBroker; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -9,9 +10,11 @@ /** * Created by jt on 6/7/17. + * just so i can commit something and see if it is working */ + @Configuration -@PropertySource("classpath:datasource.properties") +@PropertySource({"classpath:datasource.properties","classpath:jms.properties"}) public class PropertyConfig { @Value("${guru.username}") @@ -23,6 +26,15 @@ public class PropertyConfig { @Value("${guru.dburl}") String url; + @Value("${guru.jms.username}") + String jmsUsername ; + + @Value("${guru.jms.password}") + String jmsPassword ; + + @Value("${guru.jms.url}") + String jmsUrl ; + @Bean public FakeDataSource fakeDataSource(){ FakeDataSource fakeDataSource = new FakeDataSource(); @@ -32,6 +44,15 @@ public FakeDataSource fakeDataSource(){ return fakeDataSource; } + @Bean + public FakeJmsBroker fakeJmsBroker(){ + FakeJmsBroker fakeJmsBroker = new FakeJmsBroker(); + fakeJmsBroker.setUsername(jmsUsername); + fakeJmsBroker.setPassword(jmsPassword); + fakeJmsBroker.setUrl(jmsUrl); + return fakeJmsBroker; + } + @Bean public static PropertySourcesPlaceholderConfigurer properties(){ PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer =new PropertySourcesPlaceholderConfigurer(); diff --git a/src/main/java/guru/springframework/examplebeans/FakeJmsBroker.java b/src/main/java/guru/springframework/examplebeans/FakeJmsBroker.java new file mode 100644 index 00000000..01fd1607 --- /dev/null +++ b/src/main/java/guru/springframework/examplebeans/FakeJmsBroker.java @@ -0,0 +1,32 @@ +package guru.springframework.examplebeans; + +public class FakeJmsBroker { + + private String username; + private String password ; + private String url; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/src/main/resources/jms.properties b/src/main/resources/jms.properties new file mode 100644 index 00000000..d09b77db --- /dev/null +++ b/src/main/resources/jms.properties @@ -0,0 +1,3 @@ +guru.jms.username =JMS USERNAME +guru.jms.password =somepass +guru.jms.url =SomeURL \ No newline at end of file