Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing #33

Open
wants to merge 3 commits into
base: property-source
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/guru/springframework/DiDemoApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
}
23 changes: 22 additions & 1 deletion src/main/java/guru/springframework/config/PropertyConfig.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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}")
Expand All @@ -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();
Expand All @@ -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();
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/guru/springframework/examplebeans/FakeJmsBroker.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
3 changes: 3 additions & 0 deletions src/main/resources/jms.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
guru.jms.username =JMS USERNAME
guru.jms.password =somepass
guru.jms.url =SomeURL