首页 > 代码库 > ssh的配置
ssh的配置
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的配置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。