
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 xmlns:mvc="http://www.springframework.org/schema/mvc" 8 xsi:schemaLocation="http://www.springframework.org/schema/beans 9 http://www.springframework.org/schema/beans/spring-beans.xsd 10 http://www.springframework.org/schema/context 11 http://www.springframework.org/schema/context/spring-context.xsd 12 http://www.springframework.org/schema/aop 13 http://www.springframework.org/schema/aop/spring-aop.xsd 14 http://www.springframework.org/schema/tx 15 http://www.springframework.org/schema/tx/spring-tx.xsd 16 http://www.springframework.org/schema/mvc 17 http://www.springframework.org/schema/mvc/spring-mvc.xsd"> 18 19 <!--数据库连接参数--> 20 <context:property-placeholder location="classpath:druid.properties"></context:property-placeholder> 21 22 <!--数据源--> 23 <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> 24 <property name="driverClassName" value="${jdbc.driver}"></property> 25 <property name="url" value="${jdbc.url}"></property> 26 <property name="username" value="${jdbc.username}"></property> 27 <property name="password" value="${jdbc.password}"></property> 28 </bean> 29 30 <!--SqlSessionFactoryBean--> 31 <bean class="org.mybatis.spring.SqlSessionFactoryBean"> 32 <property name="dataSource" ref="dataSource"></property> 33 <property name="typeAliases"> 34 <array> 35 <value>cn.itcast.domain.Item</value> 36 </array> 37 </property> 38 </bean> 39 40 <!--mapper接口扫描--> 41 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> 42 <property name="basePackage" value="cn.itcast.dao"></property> 43 </bean> 44 45 </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 xmlns:mvc="http://www.springframework.org/schema/mvc" 8 xsi:schemaLocation="http://www.springframework.org/schema/beans 9 http://www.springframework.org/schema/beans/spring-beans.xsd 10 http://www.springframework.org/schema/context 11 http://www.springframework.org/schema/context/spring-context.xsd 12 http://www.springframework.org/schema/aop 13 http://www.springframework.org/schema/aop/spring-aop.xsd 14 http://www.springframework.org/schema/tx 15 http://www.springframework.org/schema/tx/spring-tx.xsd 16 http://www.springframework.org/schema/mvc 17 http://www.springframework.org/schema/mvc/spring-mvc.xsd"> 18 <!--扫描Service--> 19 <context:component-scan base-package="cn.itcast.service"></context:component-scan> 20 21 <!--事务配置--> 22 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 23 <property name="dataSource" ref="dataSource"></property> 24 </bean> 25 26 <tx:advice id="txAdvice"> 27 <tx:attributes> 28 <tx:method name="save*"/> 29 <tx:method name="update*"/> 30 <tx:method name="delete*"/> 31 <tx:method name="find*" read-only="true" /> 32 <tx:method name="*"/> 33 </tx:attributes> 34 </tx:advice> 35 36 <aop:config> 37 <aop:pointcut id="cut" expression="execution(* cn.itcast.service.*.*(..))"></aop:pointcut> 38 <aop:advisor advice-ref="txAdvice" pointcut-ref="cut"></aop:advisor> 39 </aop:config> 40 41 </beans>

1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:mvc="http://www.springframework.org/schema/mvc" 4 xmlns:context="http://www.springframework.org/schema/context" 5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 6 xsi:schemaLocation=" 7 http://www.springframework.org/schema/beans 8 http://www.springframework.org/schema/beans/spring-beans.xsd 9 http://www.springframework.org/schema/mvc 10 http://www.springframework.org/schema/mvc/spring-mvc.xsd 11 http://www.springframework.org/schema/context 12 http://www.springframework.org/schema/context/spring-context.xsd 13 "> 14 15 <!--控制器扫描--> 16 <context:component-scan base-package="cn.itcast.controller"></context:component-scan> 17 18 <!--注解驱动,处理器映射器默认jackson,处理器适配器--> 19 <mvc:annotation-driven></mvc:annotation-driven> 20 21 <!--静态资源处理--> 22 <mvc:default-servlet-handler></mvc:default-servlet-handler> 23 24 <!--视图解析前后缀--> 25 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 26 <property name="prefix" value="/WEB-INF/pages/"></property> 27 <property name="suffix" value=".jsp"></property> 28 </bean> 29 30 </beans>

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <!--spring容器监听器--> <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> <!--springmvc前端控制器--> <servlet> <servlet-name>app</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>app</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!--编码过滤--> <filter> <filter-name>CharacterEncodingFilter</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> <!-- 强制使用编码 * @see #setEncoding * @see #setForceEncoding --> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>

1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <modelVersion>4.0.0</modelVersion> 6 7 <groupId>cn.itcast</groupId> 8 <artifactId>maven_2_parent</artifactId> 9 <packaging>pom</packaging> 10 <version>1.0-SNAPSHOT</version> 11 <modules> 12 <module>maven_2_dao</module> 13 <module>maven_2_service</module> 14 <module>maven_2_web</module> 15 </modules> 16 17 <!-- 统一管理jar包版本 --> 18 <properties> 19 <spring.version>5.0.2.RELEASE</spring.version> 20 <slf4j.version>1.6.6</slf4j.version> 21 <log4j.version>1.2.12</log4j.version> 22 <shiro.version>1.2.3</shiro.version> 23 <mysql.version>5.1.6</mysql.version> 24 <mybatis.version>3.4.5</mybatis.version> 25 <spring.security.version>5.0.1.RELEASE</spring.security.version> 26 </properties> 27 28 <!-- 锁定jar包版本 --> 29 <dependencyManagement> 30 <dependencies> 31 <dependency> 32 <groupId>org.springframework</groupId> 33 <artifactId>spring-context</artifactId> 34 <version>${spring.version}</version> 35 </dependency> 36 <dependency> 37 <groupId>org.springframework</groupId> 38 <artifactId>spring-web</artifactId> 39 <version>${spring.version}</version> 40 </dependency> 41 <dependency> 42 <groupId>org.springframework</groupId> 43 <artifactId>spring-webmvc</artifactId> 44 <version>${spring.version}</version> 45 </dependency> 46 <dependency> 47 <groupId>org.springframework</groupId> 48 <artifactId>spring-tx</artifactId> 49 <version>${spring.version}</version> 50 </dependency> 51 <dependency> 52 <groupId>org.springframework</groupId> 53 <artifactId>spring-test</artifactId> 54 <version>${spring.version}</version> 55 </dependency> 56 <dependency> 57 <groupId>org.mybatis</groupId> 58 <artifactId>mybatis</artifactId> 59 <version>${mybatis.version}</version> 60 </dependency> 61 </dependencies> 62 </dependencyManagement> 63 64 <!-- 项目依赖jar包 --> 65 <dependencies> 66 <!-- spring --> 67 <dependency> 68 <groupId>org.aspectj</groupId> 69 <artifactId>aspectjweaver</artifactId> 70 <version>1.6.8</version> 71 </dependency> 72 <dependency> 73 <groupId>org.springframework</groupId> 74 <artifactId>spring-aop</artifactId> 75 <version>${spring.version}</version> 76 </dependency> 77 <dependency> 78 <groupId>org.springframework</groupId> 79 <artifactId>spring-context</artifactId> 80 <version>${spring.version}</version> 81 </dependency> 82 <dependency> 83 <groupId>org.springframework</groupId> 84 <artifactId>spring-context-support</artifactId> 85 <version>${spring.version}</version> 86 </dependency> 87 <dependency> 88 <groupId>org.springframework</groupId> 89 <artifactId>spring-web</artifactId> 90 <version>${spring.version}</version> 91 </dependency> 92 <dependency> 93 <groupId>org.springframework</groupId> 94 <artifactId>spring-orm</artifactId> 95 <version>${spring.version}</version> 96 </dependency> 97 <dependency> 98 <groupId>org.springframework</groupId> 99 <artifactId>spring-beans</artifactId> 100 <version>${spring.version}</version> 101 </dependency> 102 <dependency> 103 <groupId>org.springframework</groupId> 104 <artifactId>spring-core</artifactId> 105 <version>${spring.version}</version> 106 </dependency> 107 <dependency> 108 <groupId>org.springframework</groupId> 109 <artifactId>spring-test</artifactId> 110 <version>${spring.version}</version> 111 </dependency> 112 <dependency> 113 <groupId>org.springframework</groupId> 114 <artifactId>spring-webmvc</artifactId> 115 <version>${spring.version}</version> 116 </dependency> 117 <dependency> 118 <groupId>org.springframework</groupId> 119 <artifactId>spring-tx</artifactId> 120 <version>${spring.version}</version> 121 </dependency> 122 <dependency> 123 <groupId>junit</groupId> 124 <artifactId>junit</artifactId> 125 <version>4.12</version> 126 <scope>test</scope> 127 </dependency> 128 <dependency> 129 <groupId>mysql</groupId> 130 <artifactId>mysql-connector-java</artifactId> 131 <version>${mysql.version}</version> 132 </dependency> 133 <dependency> 134 <groupId>javax.servlet</groupId> 135 <artifactId>javax.servlet-api</artifactId> 136 <version>3.1.0</version> 137 <scope>provided</scope> 138 </dependency> 139 <dependency> 140 <groupId>javax.servlet.jsp</groupId> 141 <artifactId>jsp-api</artifactId> 142 <version>2.0</version> 143 <scope>provided</scope> 144 </dependency> 145 <dependency> 146 <groupId>jstl</groupId> 147 <artifactId>jstl</artifactId> 148 <version>1.2</version> 149 </dependency> 150 <!-- log start --> 151 <dependency> 152 <groupId>log4j</groupId> 153 <artifactId>log4j</artifactId> 154 <version>${log4j.version}</version> 155 </dependency> 156 <dependency> 157 <groupId>org.slf4j</groupId> 158 <artifactId>slf4j-api</artifactId> 159 <version>${slf4j.version}</version> 160 </dependency> 161 <dependency> 162 <groupId>org.slf4j</groupId> 163 <artifactId>slf4j-log4j12</artifactId> 164 <version>${slf4j.version}</version> 165 </dependency> 166 <!-- log end --> 167 <dependency> 168 <groupId>org.mybatis</groupId> 169 <artifactId>mybatis</artifactId> 170 <version>${mybatis.version}</version> 171 </dependency> 172 <dependency> 173 <groupId>org.mybatis</groupId> 174 <artifactId>mybatis-spring</artifactId> 175 <version>1.3.0</version> 176 </dependency> 177 <dependency> 178 <groupId>c3p0</groupId> 179 <artifactId>c3p0</artifactId> 180 <version>0.9.1.2</version> 181 <type>jar</type> 182 <scope>compile</scope> 183 </dependency> 184 <dependency> 185 <groupId>com.github.pagehelper</groupId> 186 <artifactId>pagehelper</artifactId> 187 <version>5.1.2</version> 188 </dependency> 189 <dependency> 190 <groupId>org.springframework.security</groupId> 191 <artifactId>spring-security-web</artifactId> 192 <version>${spring.security.version}</version> 193 </dependency> 194 <dependency> 195 <groupId>org.springframework.security</groupId> 196 <artifactId>spring-security-config</artifactId> 197 <version>${spring.security.version}</version> 198 </dependency> 199 <dependency> 200 <groupId>org.springframework.security</groupId> 201 <artifactId>spring-security-core</artifactId> 202 <version>${spring.security.version}</version> 203 </dependency> 204 <dependency> 205 <groupId>org.springframework.security</groupId> 206 <artifactId>spring-security-taglibs</artifactId> 207 <version>${spring.security.version}</version> 208 </dependency> 209 <dependency> 210 <groupId>com.alibaba</groupId> 211 <artifactId>druid</artifactId> 212 <version>1.0.9</version> 213 </dependency> 214 </dependencies> 215 <!-- 添加tomcat7插件 --> 216 <build> 217 <plugins> 218 <plugin> 219 <groupId>org.apache.tomcat.maven</groupId> 220 <artifactId>tomcat7-maven-plugin</artifactId> 221 <version>2.2</version> 222 </plugin> 223 </plugins> 224 </build> 225 </project>

1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <parent> 6 <artifactId>maven_2_parent</artifactId> 7 <groupId>cn.itcast</groupId> 8 <version>1.0-SNAPSHOT</version> 9 </parent> 10 <modelVersion>4.0.0</modelVersion> 11 12 <artifactId>maven_2_dao</artifactId> 13 14 15 </project>

1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <parent> 6 <artifactId>maven_2_parent</artifactId> 7 <groupId>cn.itcast</groupId> 8 <version>1.0-SNAPSHOT</version> 9 </parent> 10 <modelVersion>4.0.0</modelVersion> 11 12 <artifactId>maven_2_service</artifactId> 13 14 <dependencies> 15 <dependency> 16 <groupId>cn.itcast</groupId> 17 <artifactId>maven_2_dao</artifactId> 18 <version>1.0-SNAPSHOT</version> 19 </dependency> 20 </dependencies> 21 22 </project>

1 <?xml version="1.0" encoding="UTF-8"?> 2 3 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <parent> 6 <artifactId>maven_2_parent</artifactId> 7 <groupId>cn.itcast</groupId> 8 <version>1.0-SNAPSHOT</version> 9 </parent> 10 <modelVersion>4.0.0</modelVersion> 11 12 <artifactId>maven_2_web</artifactId> 13 <packaging>war</packaging> 14 15 16 <properties> 17 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 18 <maven.compiler.source>1.8</maven.compiler.source> 19 <maven.compiler.target>1.8</maven.compiler.target> 20 </properties> 21 22 <dependencies> 23 <dependency> 24 <groupId>cn.itcast</groupId> 25 <artifactId>maven_2_service</artifactId> 26 <version>1.0-SNAPSHOT</version> 27 </dependency> 28 </dependencies> 29 </project>

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 xmlns:mvc="http://www.springframework.org/schema/mvc" 8 xsi:schemaLocation="http://www.springframework.org/schema/beans 9 http://www.springframework.org/schema/beans/spring-beans.xsd 10 http://www.springframework.org/schema/context 11 http://www.springframework.org/schema/context/spring-context.xsd 12 http://www.springframework.org/schema/aop 13 http://www.springframework.org/schema/aop/spring-aop.xsd 14 http://www.springframework.org/schema/tx 15 http://www.springframework.org/schema/tx/spring-tx.xsd 16 http://www.springframework.org/schema/mvc 17 http://www.springframework.org/schema/mvc/spring-mvc.xsd"> 18 19 <import resource="classpath:spring/applicationContext-dao.xml"></import> 20 <import resource="classpath:spring/applicationContext-service.xml"></import> 21 22 </beans>

# Set root category priority to INFO and its only appender to CONSOLE. #log4j.rootCategory=INFO, CONSOLE debug info warn error fatal log4j.rootCategory=debug, CONSOLE, LOGFILE # Set the enterprise logger category to FATAL and its only appender to CONSOLE. log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE # CONSOLE is set to be a ConsoleAppender using a PatternLayout. log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m # LOGFILE is set to be a File appender using a PatternLayout. log4j.appender.LOGFILE=org.apache.log4j.FileAppender log4j.appender.LOGFILE.File=d:\axis.log log4j.appender.LOGFILE.Append=true log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout log4j.appender.LOGFILE.layout.ConversionPattern=%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m