SSh統合開発


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" 
	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/context
         http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://www.springframework.org/schema/tx 
    	 http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
         http://www.springframework.org/schema/aop 
         http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

	<context:annotation-config />
	<context:component-scan base-package="com.bjsxt" />


	<!--
		   ,         <bean id="dataSource"
		class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close"> <property name="driverClassName"
		value="com.mysql.jdbc.Driver" /> <property name="url"
		value="jdbc:mysql://localhost:3306/spring" /> <property
		name="username" value="root" /> <property name="password" value="pass"
		/> </bean>
	-->
	<!--    ,             -->
	<bean
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations" value="classpath:jdbc.properties" />
		<!--  	       -->
	</bean>
	<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource" >
		<property name="driverClassName" value="${jdbc.driverClassName}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>


	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<!--            
		<property name="annotatedClasses">
			<list>
				<value>com.bjsxt.model.User</value>
			</list>
		</property>
		 -->
		<!--                  ,       packagesToScan               -->
		<property name="packagesToScan">
			<list>
				<value>com.bjsxt.registration.model</value>
			</list>
		</property>
		
		<property name="hibernateProperties"><!--       hibernate     -->
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
				<prop key="hibernate.format_sql">true</prop>
				<prop key="current_session_context_class">thread</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>

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

	<!--   xml     -->
	<aop:config>
		<aop:pointcut expression="execution(public * com.bjsxt.registration.service.*.*(..))"
			id="businessService" />
		<aop:advisor advice-ref="txAdvice" pointcut-ref="businessService" />
	</aop:config>
	
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="exists" read-only="true" />
			<tx:method name="add*" propagation="REQUIRED" />
		</tx:attributes>
	</tx:advice>

	<!--  Spring   HibernateTemplate -->
	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>

</beans>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
	"http://struts.apache.org/dtds/struts-2.1.dtd">

<struts>
	<constant name="struts.i18n.encoding" value="utf-8"></constant><!--           jsp             -->
	<constant name="struts.devMode" value="true"></constant>
	<package name="registration" extends="struts-default">

		<action name="user" class="com.bjsxt.registration.action.UserAction">

			<result name="success">/registerSuccess.jsp</result>
			<result name="fail">/registerFail.jsp</result>

		</action>
	</package>


</struts>
	
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>

	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext.xml</param-value>
	</context-param>
</web-app>