基于注解的ssm,有restful,事务也是注解
1)jar介绍
AbsoluteLayout.jar
antlr-2.7.7.jar
aopalliance.jar
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
aspectjrt-1.7.1.jar
aspectjweaver-1.7.1.jar
c3p0-0.9.2.1.jar
commons-beanutils-1.9.2.jar
commons-betwixt-0.8.jar
commons-codec-1.9.jar
commons-collections-3.2.1.jar
commons-collections4-4.0.jar
commons-dbcp2-2.1.jar
commons-digester-2.0.jar
commons-fileupload-1.3.1.jar
commons-io-2.4.jar
commons-jexl-2.1.1.jar
commons-lang3-3.3.2.jar
commons-logging-1.2.jar
commons-pool2-2.4.1.jar
dom4j-1.6.1.jar
ehcache-2.7.4.jar
fastjson-1.1.1.jar
freemarker-2.3.22.jar
guava-18.0.jar
jackson-all-1.9.0.jar
jackson-annotations-2.2.3.jar
jackson-core-2.2.3.jar
jackson-databind-2.2.3.jar
jackson-databind-2.3.1.jar
jackson-module-jaxb-annotations-2.1.2.jar
jandex-1.1.0.Final.jar
javassist-3.18.1-GA.jar
jboss-logging-3.1.3.GA.jar
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar
joda-time-2.7.jar
json-lib-2.4-jdk15.jar
json.jar
jstl-1.2.jar
jstl-api-1.2.jar
junit-4.5.jar
jxl.jar
log4j-1.2.17.jar
logback-classic-1.0.13.jar
logback-core-1.0.13.jar
mail.jar
mchange-commons-java-0.2.3.4.jar
mybatis-3.3.1.jar
mybatis-spring-1.2.1.jar
mysql-connector-java-5.1.12-bin.jar
netty-all-5.0.0.Alpha2.jar
netty-buffer-5.0.0.Alpha2.jar
netty-codec-5.0.0.Alpha2.jar
netty-common-5.0.0.Alpha2.jar
netty-handler-5.0.0.Alpha2.jar
netty-resolver-5.0.0.Alpha2.jar
netty-transport-5.0.0.Alpha2.jar
ognl-3.0.6.jar
ojdbc6.jar
oracle11g 11.2.0.1.0 JDBC_ojdbc6.jar
quartz-1.6.4.jar
rockcomm.jar
rockcommon.jar
sigar.jar
slf4j-api-1.7.9.jar
spring-aop-4.1.3.RELEASE.jar
spring-aspects-4.1.3.RELEASE.jar
spring-beans-4.1.3.RELEASE.jar
spring-context-4.1.3.RELEASE.jar
spring-context-support.jar
spring-core-4.1.3.RELEASE.jar
spring-data-commons-1.9.1.RELEASE.jar
spring-data-jpa-1.7.1.RELEASE.jar
spring-expression-4.1.3.RELEASE.jar
spring-jdbc-4.1.3.RELEASE.jar
spring-orm-4.1.3.RELEASE.jar
spring-security-acl-4.0.2.RELEASE.jar
spring-security-aspects-4.0.2.RELEASE.jar
spring-security-cas-4.0.2.RELEASE.jar
spring-security-config-4.0.2.RELEASE.jar
spring-security-core-4.0.2.RELEASE.jar
spring-security-crypto-4.0.2.RELEASE.jar
spring-security-ldap-4.0.2.RELEASE.jar
spring-security-oauth2-2.0.7.RELEASE.jar
spring-security-openid-4.0.2.RELEASE.jar
spring-security-remoting-4.0.2.RELEASE.jar
spring-security-taglibs-4.0.2.RELEASE.jar
spring-security-web-4.0.2.RELEASE.jar
spring-test-4.1.3.RELEASE.jar
spring-tx-4.1.3.RELEASE.jar
spring-web-4.1.3.RELEASE.jar
spring-webmvc-4.1.3.RELEASE.jar
spring-webmvc-portlet-4.1.3.RELEASE.jar
spring-websocket-4.1.3.RELEASE.jar
springside-core-4.2.3-GA.jar
swing-layout-1.0.3.jar
ueditor-1.1.2.jar
xwork-core-2.3.24.1.jar
2)web.xml配置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/applicationContext*.xml</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>production</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<!-- 配置 HiddenHttpMethodFilter: 把 POST 请求转为 DELETE、PUT 请求 -->
<filter>
<filter-name>HiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>HiddenHttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
3)spring-mvc.xml配置
<?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:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射,解决@ResponseBody乱码问题, 需要在annotation-driven和component-scan之前,否则乱码问题同样无法解决 -->
<context:component-scan base-package="com.lm.ssm.action" annotation-config="true" />
<!-- <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>-->
<!--Spring3.1推荐使用RequestMappingHandlerAdapter-->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html; charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean>
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> </bean>
<!-- 将无法mapping到Controller的path交给default servlet handler处理 -->
<mvc:default-servlet-handler />
<!--Basic application beans. -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="json" value="application/json" />
</map>
</property>
<property name="viewResolvers">
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
<property name="extractValueFromSingleKeyModel" value="true" />
</bean>
</list>
</property>
</bean>
</beans>
4)applicationContext.xml配置
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<!-- ioc注解 -->
<context:component-scan base-package="com.lm.ssm" annotation-config="true"></context:component-scan>
<!-- 引入properties文件 -->
<context:property-placeholder location="classpath*:db.properties"/>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- <property name="maxUploadSize" value="100000"/>
<property name="maxInMemorySize" value="10240" /> -->
</bean>
<!-- 全局国际化资源文件配置 -->
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="fallbackToSystemLocale" value="false" />
<property name="cacheSeconds" value="10" />
<property name="basenames">
<!-- 在这里配置全局国际化资源文件列表 -->
<list>
<value>classpath:jpaResources</value>
</list>
</property>
</bean>
<!-- 配置c3p0数据源 com.mchange.v2.c3p0.ComboPooledDataSource-->
<!-- 配置dbcp2数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="url" value="${jdbcUrl}"></property>
<property name="driverClassName" value="${driverClass}"></property>
<property name="username" value="${user}"></property>
<property name="password" value="${password}"></property>
<!-- 设置连接池初始值 -->
<property name="initialSize" value="1" />
<!-- 设置连接池最大连接数 -->
<property name="maxTotal" value="10" />
<!-- 设置连接池最大空闲连接数 -->
<property name="maxIdle" value="2" />
<!-- 设置连接池最小空闲连接数 -->
<property name="minIdle" value="1" />
<!-- 设置连接池最大等待毫秒数 -->
<property name="maxWaitMillis" value="10000" />
<!-- 缺省自动提交 -->
<property name="defaultAutoCommit" value="false" />
</bean>
<!-- 配置SqlSessionFactoryBean,目的:加载mybaits配置文件和映射文件,即替代原Mybatis工具类的作用 -->
<bean id="sqlSessionFactoryBeanID" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:com/lm/ssm/vo/*.xml"/>
<property name="typeAliasesPackage" value="com.lm.ssm.vo"/>
<!-- <property name="mapperLocations" value="classpath:/mapper/*/*.xml"></property> -->
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.lm.ssm.dao" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryBeanID" />
</bean>
<!-- 确保注解DAO的 持久化异常翻译成Spring的异常-->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<!-- annotation事务 -->
<tx:annotation-driven transaction-manager="txManager" />
<!-- 配置Mybatis的事务管理器,即因为Mybatis底层用的是JDBC事务管事器,所以在这里依然配置JDBC事务管理器 -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<context:annotation-config/>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>