关闭

ssh开发 pom配置+dao配置+persistence配置

1704人阅读 评论(0) 收藏 举报
分类:

保存一份标准配置,免得以后零时组装的时候出现各种问题(其实主要的问题就是各种包的版本之间可能存在冲突,我觉得这个是java的硬伤,包太多每个包的版本又多,这样就很容易出现包冲突,而且解决这样的问题会消耗大量的时间)

pom.xml

<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>
  <groupId>com.ssh</groupId>
  <artifactId>hibernatestudy</artifactId>
  <name>hibernatestudy</name>
  <version>0.0.1-SNAPSHOT</version>
  <build>
  	<plugins>
  		<plugin>
  			<groupId>org.apache.maven.plugins</groupId>
  			<artifactId>maven-compiler-plugin</artifactId>
  		</plugin>
  	</plugins>
  </build>
  <dependencies>
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>4.10</version>
	</dependency>
	
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>5.1.6</version>
	</dependency>
	<dependency>
		<groupId>fakepath</groupId>
		<artifactId>com.springsource.org.logicalcobwebs.proxool</artifactId>
		<version>0.9.1</version>
	</dependency>
	<dependency>
		<groupId>fakepath</groupId>
		<artifactId>com.springsource.org.logicalcobwebs.cglib.core</artifactId>
		<version>0.9.1</version>
	</dependency>
  	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate</artifactId>
		<version>3.2.7.ga</version>
	</dependency>
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-annotations</artifactId>
		<version>3.4.0.GA</version>
	</dependency>
	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>slf4j-api</artifactId>
		<version>1.7.5</version>
	</dependency>
	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>slf4j-log4j12</artifactId>
		<version>1.7.5</version>
	</dependency>	

	<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>
	<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>
    <dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-test</artifactId>
		<version>3.2.5.RELEASE</version>
	</dependency>
    <dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-orm</artifactId>
		<version>3.2.5.RELEASE</version>
	</dependency>
					
  </dependencies>
  <properties>
  	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
</project>

dao-config.xml

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

	<import resource="classpath:persistence-config.xml" />

	<bean id="accountTypeDao" class="com.ssh.daoimpl.AccountTypeDaoImpl"
		p:sessionFactory-ref="sessionFactory" />
</beans>

persistence-config.xml

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:p="http://www.springframework.org/schema/p" 
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

	<bean name="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
		p:ignoreUnresolvablePlaceholders="true" p:ignoreResourceNotFound="true">
		<property name="locations">
			<list>
				<value>classpath:db.properties</value>
			</list>
		</property>
	</bean>

	<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
		<property name="driver">
			<value>${contacts.db.driver}</value>
		</property>
		<property name="driverUrl">
			<value>${contacts.db.url}</value>
		</property>
		<property name="user">
			<value>${contacts.db.username}</value>
		</property>
		<property name="password">
			<value>${contacts.db.password}</value>
		</property>
		<property name="maximumConnectionCount">
			<value>${contacts.db.maxconnection}</value>
		</property>
	</bean>
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" 
		p:dataSource-ref="dataSource">
		<property name="hibernateProperties">
			<props>
				<!-- MySQL DIALECT -->
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.show_sql">false</prop>
			</props>
		</property>
		<property name="annotatedClasses">
			<list>
				<value>
					com.ssh.model.TbbsAccountType 
				</value>	
			</list>
		</property>
	</bean>

	<!-- Spring transaction management -->
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" 
		p:sessionFactory-ref="sessionFactory" />

	<tx:annotation-driven transaction-manager="transactionManager" />

</beans>

db.propertise

#########################
# General Configuration #
#########################

#################################
# DB Connection properties  #
#################################

# MySQL Config
contacts.db.username=shine
contacts.db.password=123456
contacts.db.driver=com.mysql.jdbc.Driver
contacts.db.maxconnection=200
contacts.db.url=jdbc:mysql://192.168.2.3:3306/nsaddp?useUnicode=true&characterEncoding=utf-8






0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:572165次
    • 积分:7801
    • 等级:
    • 排名:第2782名
    • 原创:248篇
    • 转载:49篇
    • 译文:0篇
    • 评论:64条
    最新评论