persistence work

This commit is contained in:
eugenp 2013-05-04 22:44:39 +03:00
parent debee3bf5c
commit 015050f928
3 changed files with 143 additions and 129 deletions

View File

@ -11,6 +11,11 @@
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
@ -35,6 +40,13 @@
<version>4.2.1.Final</version>
</dependency>
<!-- utils -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
</dependency>
<!-- test scoped -->

View File

@ -15,6 +15,8 @@ import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBea
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.google.common.base.Preconditions;
@Configuration
@EnableTransactionManagement
@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" })
@ -40,10 +42,10 @@ public class PersistenceConfig {
@Bean
public DataSource restDataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
dataSource.setUrl(env.getProperty("jdbc.url"));
dataSource.setUsername(env.getProperty("jdbc.user"));
dataSource.setPassword(env.getProperty("jdbc.pass"));
dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName")));
dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url")));
dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user")));
dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass")));
return dataSource;
}

View File

@ -22,19 +22,19 @@
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring child -->
<servlet>
<servlet-name>mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Spring web -->
<!-- <servlet> -->
<!-- <servlet-name>mvc</servlet-name> -->
<!-- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> -->
<!-- <load-on-startup>1</load-on-startup> -->
<!-- </servlet> -->
<!-- <servlet-mapping> -->
<!-- <servlet-name>mvc</servlet-name> -->
<!-- <url-pattern>/</url-pattern> -->
<!-- </servlet-mapping> -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- <welcome-file-list> -->
<!-- <welcome-file>index.html</welcome-file> -->
<!-- </welcome-file-list> -->
</web-app>