From a49db1ff5481437b67d5f51fd7fceb55c7ffb9d5 Mon Sep 17 00:00:00 2001 From: erosai Date: Fri, 25 Dec 2020 16:16:23 +0100 Subject: [PATCH 1/3] testing --- src/main/java/guru/springframework/config/PropertyConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/guru/springframework/config/PropertyConfig.java b/src/main/java/guru/springframework/config/PropertyConfig.java index dec2094b..b908655b 100644 --- a/src/main/java/guru/springframework/config/PropertyConfig.java +++ b/src/main/java/guru/springframework/config/PropertyConfig.java @@ -9,7 +9,9 @@ /** * Created by jt on 6/7/17. + * just so i can commit something and see if it is working */ + @Configuration @PropertySource("classpath:datasource.properties") public class PropertyConfig { From d4075979817aaf40611f77c49ce8ef716e0be658 Mon Sep 17 00:00:00 2001 From: erosai Date: Fri, 25 Dec 2020 21:38:32 +0100 Subject: [PATCH 2/3] added jms properties --- .../examplebeans/FakeJmsBroker.java | 32 +++++++++++++++++++ src/main/resources/jms.properties | 3 ++ 2 files changed, 35 insertions(+) create mode 100644 src/main/java/guru/springframework/examplebeans/FakeJmsBroker.java create mode 100644 src/main/resources/jms.properties 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 From b5ff3f6117c71b60dea8d3694d816f55a118b00c Mon Sep 17 00:00:00 2001 From: erosai Date: Fri, 25 Dec 2020 22:44:40 +0100 Subject: [PATCH 3/3] added jms properties --- .../springframework/DiDemoApplication.java | 4 ++++ .../config/PropertyConfig.java | 21 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) 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 b908655b..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; @@ -13,7 +14,7 @@ */ @Configuration -@PropertySource("classpath:datasource.properties") +@PropertySource({"classpath:datasource.properties","classpath:jms.properties"}) public class PropertyConfig { @Value("${guru.username}") @@ -25,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(); @@ -34,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();