My first ssh application

我是个懒人,不习惯做笔记...很不好的习惯,所以从现在开始,慢慢改变吧

架设SSH 框架 引文缺少类包而引起的对应报错

这边文章主要针对spring jar。各种classNotFound Exception 可以到 http://www.findjar.com/去找对应的 jar

从零开始吧:
配置 spring  context listner:
web.xml
<listener>
  	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <context-param>
  	<param-name>contextConfigLocation</param-name>
  	<param-value>*/applicationContext.xml</param-value>
  </context-param>


1.Exceptin:org.springframework.web.context.ContextLoaderListener
need:spring-web.jar,spring-core.jar,sping-context.jar,spring-beans.jar,
commons-logging-1.0.4.jar,spring-jdbc.jar(Used for datasource connection),commons-collections-2.1.1.jar,dom4j-1.6.1.jar,hibernate3.jar,jta.jar

Each jar functions: http://vc88.iteye.com/blog/360703

applicationContext.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
 
<beans>
	<!-- dataSource config -->
	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName">
			<value>com.mysql.jdbc.Driver</value>
		</property>
		<property name="url">
			<value>jdbc:mysql://localhost:3306/Test</value>
		</property>
		<property name="username">
			<value>root</value>
		</property>
		<property name="password">
			<value>password</value>
		</property>
	</bean>
	
	<!-- SessionFactory -->
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

		<property name="dataSource">
			<ref bean="dataSource"/>
		</property>
		<!--<property name="configLocation">
			<value>classpath:com\game\bean\hibernate\hibernate.cfg.xml</value>
		</property>		
	--></bean>
	
	<!-- TransactionManager  -->
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory">
			<ref local="sessionFactory"/>
		</property>
	</bean>
	
	 DAO 
	<bean id="dao" class="...">
		<property name="sessionFactory">
			<ref bean="sessionFactory"/>
		</property>
	</bean>
	
	 Services 
	<bean id="service" class="...">
		<property name="dao">
			<ref bean="dao"/>
		</property>
	</bean>
	
	<bean id="pagerService" class="com.game.commons.PagerService">
	</bean>
	
	 View 
	<bean name="/getProducts" class="com.game.products.web.actions.ProductsAction" singleton="false">
		<property name="productsService">
			<ref bean="productsService"/>
		</property>
		<property name="pagerService">
			<ref bean="pagerService"/>
		</property>
	</bean>
	</bean>
</beans>

你可能感兴趣的:(spring,mysql,Hibernate,jdbc,ssh)