persistence work
This commit is contained in:
parent
debee3bf5c
commit
015050f928
|
@ -1,139 +1,151 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.baeldung</groupId>
|
<groupId>org.baeldung</groupId>
|
||||||
<artifactId>spring-hibernate-dao</artifactId>
|
<artifactId>spring-hibernate-dao</artifactId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>spring-hibernate-dao</name>
|
<name>spring-hibernate-dao</name>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-orm</artifactId>
|
<artifactId>spring-web</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${org.springframework.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context</artifactId>
|
<artifactId>spring-orm</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${org.springframework.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context</artifactId>
|
||||||
|
<version>${org.springframework.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- persistence -->
|
<!-- persistence -->
|
||||||
|
|
||||||
<!-- <dependency> -->
|
<!-- <dependency> -->
|
||||||
<!-- <groupId>org.hibernate</groupId> -->
|
<!-- <groupId>org.hibernate</groupId> -->
|
||||||
<!-- <artifactId>hibernate-entitymanager</artifactId> -->
|
<!-- <artifactId>hibernate-entitymanager</artifactId> -->
|
||||||
<!-- <version>4.2.1.Final</version> -->
|
<!-- <version>4.2.1.Final</version> -->
|
||||||
<!-- </dependency> -->
|
<!-- </dependency> -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-core</artifactId>
|
<artifactId>hibernate-core</artifactId>
|
||||||
<version>4.2.1.Final</version>
|
<version>4.2.1.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- utils -->
|
||||||
|
|
||||||
<!-- test scoped -->
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>14.0.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- test scoped -->
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit-dep</artifactId>
|
|
||||||
<version>${junit.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>hamcrest-core</artifactId>
|
<artifactId>junit-dep</artifactId>
|
||||||
<version>${org.hamcrest.version}</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.hamcrest</groupId>
|
|
||||||
<artifactId>hamcrest-library</artifactId>
|
|
||||||
<version>${org.hamcrest.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>hamcrest-core</artifactId>
|
||||||
<version>${mockito.version}</version>
|
<version>${org.hamcrest.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hamcrest</groupId>
|
||||||
|
<artifactId>hamcrest-library</artifactId>
|
||||||
|
<version>${org.hamcrest.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<version>${mockito.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<build>
|
</dependencies>
|
||||||
<finalName>spring-hibernate-dao</finalName>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
<build>
|
||||||
|
<finalName>spring-hibernate-dao</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
<plugin>
|
<plugins>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<!-- <exclude>**/*ProductionTest.java</exclude> -->
|
|
||||||
</excludes>
|
|
||||||
<systemPropertyVariables>
|
|
||||||
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
|
|
||||||
</systemPropertyVariables>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.cargo</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>cargo-maven2-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<wait>true</wait>
|
<excludes>
|
||||||
<container>
|
<!-- <exclude>**/*ProductionTest.java</exclude> -->
|
||||||
<containerId>jetty8x</containerId>
|
</excludes>
|
||||||
<type>embedded</type>
|
<systemPropertyVariables>
|
||||||
<systemProperties>
|
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
|
||||||
<!-- <provPersistenceTarget>cargo</provPersistenceTarget> -->
|
</systemPropertyVariables>
|
||||||
</systemProperties>
|
</configuration>
|
||||||
</container>
|
</plugin>
|
||||||
<configuration>
|
|
||||||
<properties>
|
|
||||||
<cargo.servlet.port>8082</cargo.servlet.port>
|
|
||||||
</properties>
|
|
||||||
</configuration>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
<plugin>
|
||||||
|
<groupId>org.codehaus.cargo</groupId>
|
||||||
|
<artifactId>cargo-maven2-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<wait>true</wait>
|
||||||
|
<container>
|
||||||
|
<containerId>jetty8x</containerId>
|
||||||
|
<type>embedded</type>
|
||||||
|
<systemProperties>
|
||||||
|
<!-- <provPersistenceTarget>cargo</provPersistenceTarget> -->
|
||||||
|
</systemProperties>
|
||||||
|
</container>
|
||||||
|
<configuration>
|
||||||
|
<properties>
|
||||||
|
<cargo.servlet.port>8082</cargo.servlet.port>
|
||||||
|
</properties>
|
||||||
|
</configuration>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
</build>
|
</plugins>
|
||||||
|
|
||||||
<properties>
|
</build>
|
||||||
<!-- Spring -->
|
|
||||||
<org.springframework.version>3.2.2.RELEASE</org.springframework.version>
|
|
||||||
|
|
||||||
<!-- logging -->
|
<properties>
|
||||||
<org.slf4j.version>1.7.5</org.slf4j.version>
|
<!-- Spring -->
|
||||||
<logback.version>1.0.11</logback.version>
|
<org.springframework.version>3.2.2.RELEASE</org.springframework.version>
|
||||||
|
|
||||||
<!-- testing -->
|
<!-- logging -->
|
||||||
<org.hamcrest.version>1.3</org.hamcrest.version>
|
<org.slf4j.version>1.7.5</org.slf4j.version>
|
||||||
<junit.version>4.11</junit.version>
|
<logback.version>1.0.11</logback.version>
|
||||||
<mockito.version>1.9.5</mockito.version>
|
|
||||||
|
|
||||||
<httpcore.version>4.2.4</httpcore.version>
|
<!-- testing -->
|
||||||
<httpclient.version>4.2.4</httpclient.version>
|
<org.hamcrest.version>1.3</org.hamcrest.version>
|
||||||
|
<junit.version>4.11</junit.version>
|
||||||
|
<mockito.version>1.9.5</mockito.version>
|
||||||
|
|
||||||
<rest-assured.version>1.8.0</rest-assured.version>
|
<httpcore.version>4.2.4</httpcore.version>
|
||||||
<groovy.version>1.8.9</groovy.version>
|
<httpclient.version>4.2.4</httpclient.version>
|
||||||
|
|
||||||
</properties>
|
<rest-assured.version>1.8.0</rest-assured.version>
|
||||||
|
<groovy.version>1.8.9</groovy.version>
|
||||||
|
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -15,6 +15,8 @@ import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBea
|
||||||
import org.springframework.orm.hibernate4.HibernateTransactionManager;
|
import org.springframework.orm.hibernate4.HibernateTransactionManager;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" })
|
@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" })
|
||||||
|
@ -40,10 +42,10 @@ public class PersistenceConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource restDataSource() {
|
public DataSource restDataSource() {
|
||||||
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||||
dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
|
dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName")));
|
||||||
dataSource.setUrl(env.getProperty("jdbc.url"));
|
dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url")));
|
||||||
dataSource.setUsername(env.getProperty("jdbc.user"));
|
dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user")));
|
||||||
dataSource.setPassword(env.getProperty("jdbc.pass"));
|
dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass")));
|
||||||
|
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,19 +22,19 @@
|
||||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
|
|
||||||
<!-- Spring child -->
|
<!-- Spring web -->
|
||||||
<servlet>
|
<!-- <servlet> -->
|
||||||
<servlet-name>mvc</servlet-name>
|
<!-- <servlet-name>mvc</servlet-name> -->
|
||||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
<!-- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> -->
|
||||||
<load-on-startup>1</load-on-startup>
|
<!-- <load-on-startup>1</load-on-startup> -->
|
||||||
</servlet>
|
<!-- </servlet> -->
|
||||||
<servlet-mapping>
|
<!-- <servlet-mapping> -->
|
||||||
<servlet-name>mvc</servlet-name>
|
<!-- <servlet-name>mvc</servlet-name> -->
|
||||||
<url-pattern>/</url-pattern>
|
<!-- <url-pattern>/</url-pattern> -->
|
||||||
</servlet-mapping>
|
<!-- </servlet-mapping> -->
|
||||||
|
|
||||||
<welcome-file-list>
|
<!-- <welcome-file-list> -->
|
||||||
<welcome-file>index.html</welcome-file>
|
<!-- <welcome-file>index.html</welcome-file> -->
|
||||||
</welcome-file-list>
|
<!-- </welcome-file-list> -->
|
||||||
|
|
||||||
</web-app>
|
</web-app>
|
Loading…
Reference in New Issue