码迷,mamicode.com
首页 > 其他好文 > 详细

ssh的配置

时间:2016-12-19 14:20:25      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:mysql   man   xsd   save   viso   roo   val   cal   事务管理   

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app version="3.0" 
 3     xmlns="http://java.sun.com/xml/ns/javaee" 
 4     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 5     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
 6     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
 7   <display-name></display-name>    
 8   <welcome-file-list>
 9     <welcome-file>index.jsp</welcome-file>
10   </welcome-file-list>
11   
12    <servlet>  
13       <servlet-name>spring</servlet-name>  
14     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
15     <!-- --> 
16     <init-param>         
17         <param-name>contextConfigLocation</param-name>       
18         <param-value>/WEB-INF/spring-common.xml,/WEB-INF/spring-servlet.xml</param-value>        
19     </init-param>
20            
21     <load-on-startup>1</load-on-startup>  
22   </servlet>  
23   <servlet-mapping>  
24     <servlet-name>spring</servlet-name>  
25     <url-pattern>*.do</url-pattern>  
26   </servlet-mapping>  
27   
28   <!-- 配置字符集过滤器 -->
29   <filter>
30     <filter-name>encodingFilter</filter-name>
31     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
32     <init-param>
33         <param-name>encoding</param-name>
34         <param-value>UTF-8</param-value>
35     </init-param>
36   </filter>
37   <!-- 配置项目的编码mapping -->
38   <filter-mapping>
39     <filter-name>encodingFilter</filter-name>
40     <url-pattern>/*</url-pattern>
41   </filter-mapping>
42   
43 </web-app>
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans" 
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 4     xmlns:p="http://www.springframework.org/schema/p" 
 5     xmlns:context="http://www.springframework.org/schema/context" 
 6     xmlns:mvc="http://www.springframework.org/schema/mvc" 
 7     xsi:schemaLocation="http://www.springframework.org/schema/beans   
 8     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
 9     http://www.springframework.org/schema/context  
10     http://www.springframework.org/schema/context/spring-context-3.0.xsd  
11     http://www.springframework.org/schema/mvc  
12     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd  
13     ">
14         
15     <!-- 启动包扫描功能,以便注册带有@Controller、@Service、@repository、@Component等注解的类成为spring的bean -->   
16     <context:component-scan base-package="com.wen.*">  
17         <context:include-filter type="regex" expression="controller"/>
18     </context:component-scan>
19     
20     <!-- 启动注解驱动的Spring MVC功能,注册请求url和注解POJO类方法的映射 -->
21     <mvc:annotation-driven />  
22         
23     <!-- 配置试图解析器(ViewResolver)对模型视图名称添加前后缀  --> 
24     <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
25         <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>  
26         <property name="prefix" value="/WEB-INF/jsp/" />  
27         <property name="suffix" value=".jsp" />  
28     </bean>      
29 </beans>
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"  
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
 4     xmlns:context="http://www.springframework.org/schema/context"  
 5     xmlns:aop="http://www.springframework.org/schema/aop"  
 6     xmlns:tx="http://www.springframework.org/schema/tx"  
 7     xsi:schemaLocation="http://www.springframework.org/schema/beans  
 8            http://www.springframework.org/schema/beans/spring-beans-3.2.xsd  
 9            http://www.springframework.org/schema/context  
10            http://www.springframework.org/schema/context/spring-context-3.2.xsd  
11            http://www.springframework.org/schema/aop  
12            http://www.springframework.org/schema/aop/spring-aop-3.2.xsd  
13            http://www.springframework.org/schema/tx  
14            http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> 
15            
16     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">  
17         <property value="com.mysql.jdbc.Driver" name="driverClass"/>
18     <property value="jdbc:mysql://localhost:3306/ssh" name="jdbcUrl"/>
19     <property value="root" name="user"/>
20     <property value="root" name="password"/> 
21      </bean> 
22      
23     <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
24         <property name="dataSource" ref="dataSource"/>
25         
26         <!-- 需要映射的实体类,指定到实体类所在的包即可 -->          
27         <property name="packagesToScan"> 
28             <list>   
29                 <value>com.wen.entity</value>       
30             </list>  
31         </property>   
32          
33         <property name="hibernateProperties">
34             <props>                
35                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
36                 <prop key="hibernate.show_sql">true</prop>
37                 <prop key="hibernate.format_sql">true</prop>  
38                 <prop key="hibernate.hbm2ddl.auto">update</prop>
39                 <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop>                            
40             </props>
41         </property>
42         
43     </bean>
44     
45     <bean id="transactionManager" class ="org.springframework.orm.hibernate4.HibernateTransactionManager">
46         <property name="sessionFactory" ref="sessionFactory" />
47     </bean>
48     
49     <!-- 开启事务管理 -->  
50     <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">  
51         <property name="sessionFactory" ref="sessionFactory" />  
52     </bean>      
53      
54     <aop:config>  
55         <!-- 第一个*代表所有的返回值类型;第二个*代表所有的类;第三个*代表类所有方法;..代表子或者孙子包;最后一个..代表所有的参数 -->
56         <!-- 只对业务逻辑层实施事务 --> 
57         <aop:pointcut id="txPointcut" expression="execution(* com.wen..service..*.*(..))" />  
58         <aop:advisor pointcut-ref="txPointcut" advice-ref="txAdvice" />  
59     </aop:config> 
60     
61     <!-- 使用声明式事务 -->  
62     <tx:advice id="txAdvice" transaction-manager="txManager">    
63         <tx:attributes>  
64             <tx:method name="find*" read-only="true"/>  
65             <tx:method name="get*" read-only="true"/>
66             <tx:method name="check*" read-only="true"/>
67             <tx:method name="init*" read-only="true"/>
68             <tx:method name="save*"/>  
69             <tx:method name="add*"/>  
70             <tx:method name="update*"/>  
71             <tx:method name="delete*"/>  
72             <tx:method name="execute*"/> 
73             <tx:method name="*"/>
74         </tx:attributes>  
75     </tx:advice>  
76             
77     
78 </beans>

 

ssh的配置

标签:mysql   man   xsd   save   viso   roo   val   cal   事务管理   

原文地址:http://www.cnblogs.com/xmuwenxiang/p/6196857.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!