Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import javax.sql.DataSource;

import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
Expand All @@ -30,13 +32,18 @@
@ComponentScan(basePackages = { "com.imt.test" })
@EnableTransactionManagement
@EnableJpaRepositories("com.imt.test.persistence.repo")
@PropertySource(value = { "application.properties" })
public class PersistenceContextConfig {

@Value("${db.url}")
private String dbUrl;

@Bean
public DataSource dataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/imti");
//dataSource.setUrl(dbUrl);
dataSource.setUsername("root");
dataSource.setPassword("root");
return dataSource;
Expand Down Expand Up @@ -77,4 +84,10 @@ Properties jpaProperties() {
return prop;

}

@Bean
public PropertyPlaceholderConfigurer configurer() {
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
return configurer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
@ComponentScan(basePackages = { "com.imt.test" }, excludeFilters = { @Filter(type = FilterType.ANNOTATION, value = EnableWebMvc.class) })
public class RootConfig {



}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
*/
package com.imt.test.web.config;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
Expand All @@ -20,6 +22,7 @@
@EnableWebMvc
@Configuration
@ComponentScan(basePackages = { "com.imt.test" })
@PropertySource(value = { "application.properties" })
public class WebMvcConfig extends WebMvcConfigurerAdapter {

@Bean
Expand All @@ -44,4 +47,10 @@ public ControllerClassNameHandlerMapping controllerClassNameHandlerMapping() {

}

@Bean
public PropertyPlaceholderConfigurer configurer() {
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
return configurer;
}

}
1 change: 1 addition & 0 deletions TestWS-web/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db.url=jdbc:mysql://localhost:3306/imti
1 change: 1 addition & 0 deletions TestWS-web/src/main/webapp/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db.url=jdbc:mysql://localhost:3306/imti