springMVC注解:@Controller @Service @Repository 分别标注于web层,service层,dao层。
web.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> 3 <context-param> 4 <param-name>contextConfigLocation</param-name> 5 <param-value>classpath:/spring-jdbc.xml</param-value> 6 </context-param> 7 <context-param> 8 <param-name>logbackConfigLocation</param-name> 9 <param-value>classpath:logback.xml</param-value> 10 </context-param> 11 <listener> 12 <listener-class>ch.qos.logback.ext.spring.web.LogbackConfigListener</listener-class> 13 </listener> 14 <listener> 15 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 16 </listener> 17 <servlet> 18 <servlet-name>spring-mvc</servlet-name> 19 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 20 <init-param> 21 <param-name>contextConfigLocation</param-name> 22 <param-value>classpath:/spring-servlet.xml</param-value> 23 </init-param> 24 <load-on-startup>1</load-on-startup> 25 </servlet> 26 <servlet-mapping> 27 <servlet-name>spring-mvc</servlet-name> 28 <url-pattern>/</url-pattern> 29 </servlet-mapping> 30 <servlet-mapping> 31 <!-- 这个URL由springMVC框架拦截处理 --> 32 <servlet-name>spring-mvc</servlet-name> 33 <url-pattern>/rootpath</url-pattern> 34 </servlet-mapping> 35 <welcome-file-list> 36 <!-- 相当于请求/rootpath的get方法的requestURL,避免在jsp中再做根目录跳转 --> 37 <welcome-file>rootpath</welcome-file> 38 </welcome-file-list> 39 <filter> 40 <filter-name>encodingFilter</filter-name> 41 <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 42 </filter> 43 <filter-mapping> 44 <filter-name>encodingFilter</filter-name> 45 <url-pattern>/</url-pattern> 46 </filter-mapping> 47 </web-app>
spring-servlet.xml
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" xmlns:p="http://www.springframework.org/schema/p" 4 xmlns:context="http://www.springframework.org/schema/context" 5 xmlns:mvc="http://www.springframework.org/schema/mvc" 6 xsi:schemaLocation=" 7 http://www.springframework.org/schema/beans 8 http://www.springframework.org/schema/beans/spring-beans-4.3.xsd 9 http://www.springframework.org/schema/context 10 http://www.springframework.org/schema/context/spring-context-4.3.xsd 11 http://www.springframework.org/schema/mvc 12 http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"> 13 14 <!-- 启动扫描所有的controller aokunsang--> 15 <context:component-scan base-package="com.coglink.tools.web"/> 16 17 <!-- spring国际化 --> 18 <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> 19 <!-- 国际化信息所在的文件名 --> 20 <property name="basename" value="i18n.i18n" /> 21 <!-- 如果在国际化资源文件中找不到对应代码的信息,就用这个代码作为名称 --> 22 <property name="useCodeAsDefaultMessage" value="true" /> 23 </bean> 24 25 <!-- 定义注解驱动Controller方法处理适配器 ,注:该适配器必须声明在<mvc:annotation-driven />之前,否则不能正常处理参数类型的转换 --> 26 <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> 27 <property name="messageConverters"> 28 <list> 29 <bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" /> 30 <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" > 31 <property name="objectMapper"> 32 <bean class="com.fasterxml.jackson.databind.ObjectMapper"> 33 <property name="dateFormat"> 34 <bean class="java.text.SimpleDateFormat"> 35 <!-- 设置全局返回JSON到前端时日期格式化 --> 36 <constructor-arg type="java.lang.String" value="yyyy-MM-dd HH:mm:ss"/> 37 </bean> 38 </property> 39 </bean> 40 </property> 41 </bean> 42 </list> 43 </property> 44 </bean> 45 46 <!-- 会自动注册RequestMappingHandlerMapping与RequestMappingHandlerAdapter 47 两个bean,是spring MVC为@Controllers分发请求所必须的。 并提供了:数据绑定支持,@NumberFormatannotation支持,@DateTimeFormat支持,@Valid支持,读写XML的支持(JAXB),读写JSON的支持(Jackson) --> 48 <!-- <mvc:annotation-driven /> --> 49 <mvc:annotation-driven> 50 <mvc:argument-resolvers> 51 <bean class="com.coglink.tools.web.JsonObjectArgResolverHandler"></bean> 52 </mvc:argument-resolvers> 53 </mvc:annotation-driven> 54 55 <!-- 配置js,css等静态文件直接映射到对应的文件夹,不被DispatcherServlet处理 --> 56 <mvc:resources mapping="/resources/**" location="/resources/" /> 57 58 <!-- jsp页面解析器,当Controller返回XXX字符串时,先通过拦截器,然后该类就会在/WEB-INF/views/目录下,查找XXX.jsp文件--> 59 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 60 <property name="prefix" value="/WEB-INF/views"></property> 61 <property name="suffix" value=".jsp"></property> 62 </bean> 63 64 </beans>
spring-jdbc.xml
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:aop="http://www.springframework.org/schema/aop" 5 xmlns:tx="http://www.springframework.org/schema/tx" 6 xmlns:context="http://www.springframework.org/schema/context" 7 xsi:schemaLocation=" 8 http://www.springframework.org/schema/beans 9 http://www.springframework.org/schema/beans/spring-beans-4.3.xsd 10 http://www.springframework.org/schema/tx 11 http://www.springframework.org/schema/tx/spring-tx-4.3.xsd 12 http://www.springframework.org/schema/context 13 http://www.springframework.org/schema/context/spring-context-4.3.xsd 14 http://www.springframework.org/schema/aop 15 http://www.springframework.org/schema/aop/spring-aop-4.3.xsd" default-autowire="byName"> 16 17 <!-- 多个properties文件占位符 --> 18 <context:property-placeholder location="classpath:jdbc.properties,classpath:redis.properties"/> 19 20 <!-- redis配置 --> 21 <bean id="redisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> 22 <property name="maxIdle" value="${redis.maxIdle}" /> 23 <property name="minIdle" value="${redis.minIdle}" /> 24 <property name="maxTotal" value="${redis.maxTotal}" /> 25 <property name="maxWaitMillis" value="${redis.maxWaitMillis}" /> 26 <property name="testOnBorrow" value="${redis.testOnBorrow}" /> 27 <property name="testOnReturn" value="${redis.testOnReturn}" /> 28 <property name="testWhileIdle" value="${redis.testWhileIdle}" /> 29 <property name="numTestsPerEvictionRun" value="${redis.numTestsPerEvictionRun}" /> 30 <property name="timeBetweenEvictionRunsMillis" value="${redis.timeBetweenEvictionRunsMillis}" /> 31 </bean> 32 <!-- redis连接池 --> 33 <bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> 34 <property name="hostName" value="${redis.host}"/> 35 <property name="port" value="${redis.port}"/> 36 <property name="usePool" value="true"/> 37 <property name="poolConfig" ref="redisPoolConfig"/> 38 </bean> 39 40 <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"> 41 <property name="connectionFactory" ref="redisConnectionFactory"/> 42 <property name="keySerializer"> 43 <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> 44 </property> 45 <property name="hashKeySerializer"> 46 <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> 47 </property> 48 <property name="valueSerializer"> 49 <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" /> 50 </property> 51 <property name="hashValueSerializer"> 52 <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" /> 53 </property> 54 </bean> 55 56 <!-- 加载config.properties bean类里面用法: 57 @Value("#{sql['selectUsers']}") 58 private String selectUsers; 59 60 properties文件里面写法(sql太长用隔开换行,后面不可以跟任何字符包括空格,否则SQL隔开失败): 61 62 selectUsers=select * from T_USERS WHERE 63 64 USERNAME = 'xx' AND AGE = xx 65 66 --> 67 <bean id="sql" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 68 <!-- false表示当没找到这个配置文件时,应用程序应该报错 --> 69 <property name="ignoreResourceNotFound" value="false" /> 70 <property name="locations"> 71 <list> 72 <value>classpath*:sql/*-sql.properties</value> 73 <value>classpath*:prop.properties</value> 74 </list> 75 </property> 76 </bean> 77 78 <!-- springJDBC连接池 --> 79 <!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 80 <property name="driverClassName" value="${mysql.driverclass}"/> 81 <property name="url" value="${mysql.jdbcurl}"/> 82 <property name="username" value="${mysql.user}"/> 83 <property name="password" value="${mysql.password}"/> 84 </bean> --> 85 86 <!-- alibaba-druid连接池 --> 87 <!-- <bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> 88 <property name="url" value="${jdbc_url}" /> 89 <property name="username" value="${jdbc_username}" /> 90 <property name="password" value="${jdbc_password}" /> 91 <property name="initialSize" value="${jdbc_initialSize}" /> 92 <property name="maxActive" value="${jdbc_maxActive}" /> 93 <property name="minIdle" value="${jdbc_minIdle}" /> 94 <property name="maxWait" value="${jdbc_maxWait}" /> 95 <property name="validationQuery" value="SELECT 1 FROM DUAL" /> 96 <property name="testOnBorrow" value="false" /> 97 <property name="testOnReturn" value="false" /> 98 <property name="testWhileIdle" value="true" /> 99 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 100 <property name="timeBetweenEvictionRunsMillis" value="60000" /> 101 打开removeAbandoned功能 102 <property name="removeAbandoned" value="true" /> 103 1800秒,也就是30分钟 104 <property name="removeAbandonedTimeout" value="180" /> 105 关闭abanded连接时输出错误日志 106 <property name="logAbandoned" value="true" /> 107 监控数据库 108 <property name="filters" value="mergeStat" /> 109 </bean> --> 110 111 <!-- springJDBC连接池 --> 112 <bean id="dataSource" 113 class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 114 <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> 115 <property name="url" value="${jdbc_url}"/> 116 <property name="username" value="${jdbc_username}"/> 117 <property name="password" value="${jdbc_password}"/> 118 </bean> 119 120 <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> 121 <property name = "dataSource" ref="dataSource" /> 122 </bean> 123 124 <bean id="namedParameterJdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate"> 125 <constructor-arg ref="dataSource" /> 126 </bean> 127 128 <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 129 <property name="dataSource" ref="dataSource"></property> 130 </bean> 131 132 <!-- 声明式事务管理,拦截多个包下面事物 and execution(* com.coglink.command.service.*Service.*(..)) --> 133 <aop:config> 134 <aop:advisor pointcut="execution(* com.coglink.tools.service.*Service.*(..)) and execution(* com.coglink.command.service.*Service.*(..))" advice-ref="myAdvice"/> 135 </aop:config> 136 <tx:advice id="myAdvice" transaction-manager="txManager"> 137 <tx:attributes> 138 <tx:method name="add*" propagation="REQUIRED"/> 139 <tx:method name="update*" propagation="REQUIRED"/> 140 <tx:method name="addCommandExec" propagation="REQUIRES_NEW"/> <!-- 这个名字的service方法使用新事物,不使用继承事物 --> 141 <tx:method name="*" read-only="true"/> 142 <!-- <tx:method name="*" read-only="true" rollback-for="com.smvc.util.DaoException"/> --> 143 </tx:attributes> 144 </tx:advice> 145 146 <!-- 自动扫描组件,多个包用逗号隔开,需要把controller去掉,否则影响事务管理 --> 147 <context:component-scan base-package="com.coglink.tools,com.coglink.command"> 148 <context:exclude-filter type="regex" expression="com.coglink.tools.web.*"/> 149 </context:component-scan> 150 151 </beans>
logback.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <configuration scan="false" scanPeriod="3 seconds"> 3 <contextName>IntranetTools</contextName> 4 <property name="contextName" value="IntranetTools" /> 5 <!-- 本地开发环境 --> 6 <property name="log_dir" value="logs/IntranetTools" /> 7 <!-- 控制台打印 --> 8 <appender name="ConsoleAppender" class="ch.qos.logback.core.ConsoleAppender"> 9 <encoder> 10 <!-- %logger输出完整类名 %file仅输出类名 --> 11 <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %msg %file:%line%n 12 </Pattern> 13 </encoder> 14 </appender> 15 <!-- 每天记录info级别日志文件 --> 16 <appender name="InfoRollingFileAppender" 17 class="ch.qos.logback.core.rolling.RollingFileAppender"> 18 <!-- <Encoding>UTF-8</Encoding> --> 19 <Prudent>true</Prudent> 20 <layout class="ch.qos.logback.classic.PatternLayout"> 21 <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %msg %file:%line%n 22 </Pattern> 23 </layout> 24 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 25 <FileNamePattern>${log_dir}/${contextName}%d{yyyy-MM-dd}info.log 26 </FileNamePattern> 27 </rollingPolicy> 28 <!-- 级别过滤器。如果日志级别低于WARN,将被过滤掉。 --> 29 <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> 30 <level>INFO</level> 31 </filter> 32 <!-- 除了DEBUG级别的日志,其它什么级别的日志都不要 --> 33 <!-- <filter class="ch.qos.logback.classic.filter.LevelFilter"> 34 <level>DEBUG</level> 35 <level>INFO</level> 36 <onMatch>ACCEPT</onMatch> 37 <onMismatch>DENY </onMismatch> 38 </filter> --> 39 </appender> 40 <!-- 每天生成错误日志文件 --> 41 <appender name="ErrorRollingFileAppender" 42 class="ch.qos.logback.core.rolling.RollingFileAppender"> 43 <!-- <Encoding>UTF-8</Encoding> --> 44 <Prudent>true</Prudent> 45 <layout class="ch.qos.logback.classic.PatternLayout"> 46 <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %msg %file:%line%n 47 </Pattern> 48 </layout> 49 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 50 <FileNamePattern>${log_dir}/${contextName}%d{yyyy-MM-dd}error.log 51 </FileNamePattern> 52 </rollingPolicy> 53 <!-- 级别过滤器。如果日志级别低于WARN,将被过滤掉。 --> 54 <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> 55 <level>WARN</level> 56 </filter> 57 </appender> 58 59 <logger name="com.coglink" additivity="false"> 60 <appender-ref ref="ConsoleAppender" /> 61 <appender-ref ref="InfoRollingFileAppender" /> 62 <appender-ref ref="ErrorRollingFileAppender" /> 63 </logger> 64 <!-- 从低到高ALL、 TRACE 、 DEBUG 、INFO 、WARN 、ERROR 、OFF 参考ch.qos.logback.classic.Level类 --> 65 <!-- <root level="INFO"> 这个root由logger节点替代,因为可以分不同包管理不同的日志文件 <appender-ref 66 ref="ConsoleAppender" /> <appender-ref ref="ErrorRollingFileAppender" /> 67 <appender-ref ref="MonitorAppender" /> </root> --> 68 </configuration>
redis.properties
1 redis.maxIdle=200 2 redis.minIdle=10 3 redis.maxTotal=1024 4 redis.maxWaitMillis=2000 5 redis.testOnBorrow=true 6 redis.testOnReturn=true 7 redis.testWhileIdle=true 8 redis.numTestsPerEvictionRun=10 9 redis.timeBetweenEvictionRunsMillis=60000 10 #无论是正式环境、开发环境、测试环境都是127.0.0.1,端口都是7373 11 redis.host=127.0.0.1 12 redis.port=7373
pom.xml
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 2 <modelVersion>4.0.0</modelVersion> 3 <groupId>com.coglink</groupId> 4 <artifactId>IntranetTools</artifactId> 5 <version>1.0</version> 6 <packaging>war</packaging> 7 <name>IntranetTools</name> 8 <properties> 9 <!-- <spring.version>4.0.2.RELEASE</spring.version> --> 10 <spring.version>4.3.10.RELEASE</spring.version> 11 <commons.version>2.4</commons.version> 12 </properties> 13 14 <dependencies> 15 <dependency> 16 <groupId>cglib</groupId> 17 <artifactId>cglib</artifactId> 18 <version>3.2.4</version> 19 </dependency> 20 21 <dependency> 22 <groupId>redis.clients</groupId> 23 <artifactId>jedis</artifactId> 24 <version>2.7.3</version> 25 </dependency> 26 <dependency> 27 <groupId>org.springframework.data</groupId> 28 <artifactId>spring-data-redis</artifactId> 29 <version>1.6.0.RELEASE</version> 30 </dependency> 31 <dependency> 32 <groupId>org.apache.poi</groupId> 33 <artifactId>poi</artifactId> 34 <version>3.16</version> 35 </dependency> 36 <dependency> 37 <groupId>org.apache.poi</groupId> 38 <artifactId>poi-ooxml</artifactId> 39 <version>3.16</version> 40 </dependency> 41 <dependency> 42 <groupId>com.oracle</groupId> 43 <artifactId>ojdbc6</artifactId> 44 <version>11.2.0.1.0</version> 45 </dependency> 46 <dependency> 47 <groupId>com.alibaba</groupId> 48 <artifactId>druid</artifactId> 49 <version>0.2.9</version> 50 </dependency> 51 <dependency> 52 <groupId>org.aspectj</groupId> 53 <artifactId>aspectjweaver</artifactId> 54 <version>1.8.9</version> 55 </dependency> 56 <dependency> 57 <groupId>javax.servlet</groupId> 58 <artifactId>javax.servlet-api</artifactId> 59 <version>3.1.0</version> 60 </dependency> 61 <dependency> 62 <groupId>com.alibaba</groupId> 63 <artifactId>fastjson</artifactId> 64 <version>1.1.28</version> 65 </dependency> 66 <dependency> 67 <groupId>net.sf.json-lib</groupId> 68 <artifactId>json-lib</artifactId> 69 <version>${commons.version}</version> 70 <classifier>jdk15</classifier> 71 </dependency> 72 <dependency> 73 <groupId>commons-lang</groupId> 74 <artifactId>commons-lang</artifactId> 75 <version>${commons.version}</version> 76 </dependency> 77 <dependency> 78 <groupId>commons-io</groupId> 79 <artifactId>commons-io</artifactId> 80 <version>2.4</version> 81 </dependency> 82 <dependency> 83 <groupId>org.apache.httpcomponents</groupId> 84 <artifactId>httpclient</artifactId> 85 <version>4.5.2</version> 86 </dependency> 87 88 <dependency> 89 <groupId>org.springframework</groupId> 90 <artifactId>spring-context</artifactId> 91 <version>${spring.version}</version> 92 </dependency> 93 <dependency> 94 <groupId>org.springframework</groupId> 95 <artifactId>spring-beans</artifactId> 96 <version>${spring.version}</version> 97 </dependency> 98 <dependency> 99 <groupId>org.springframework</groupId> 100 <artifactId>spring-core</artifactId> 101 <version>${spring.version}</version> 102 </dependency> 103 <dependency> 104 <groupId>org.springframework</groupId> 105 <artifactId>spring-webmvc</artifactId> 106 <version>${spring.version}</version> 107 </dependency> 108 <dependency> 109 <groupId>org.springframework</groupId> 110 <artifactId>spring-web</artifactId> 111 <version>${spring.version}</version> 112 </dependency> 113 <dependency> 114 <groupId>org.springframework</groupId> 115 <artifactId>spring-jms</artifactId> 116 <version>${spring.version}</version> 117 </dependency> 118 <dependency> 119 <groupId>org.springframework</groupId> 120 <artifactId>spring-orm</artifactId> 121 <version>${spring.version}</version> 122 </dependency> 123 <dependency> 124 <groupId>org.springframework</groupId> 125 <artifactId>spring-test</artifactId> 126 <version>${spring.version}</version> 127 </dependency> 128 <dependency> 129 <groupId>org.springframework</groupId> 130 <artifactId>spring-jdbc</artifactId> 131 <version>${spring.version}</version> 132 </dependency> 133 <dependency> 134 <groupId>org.springframework</groupId> 135 <artifactId>spring-aop</artifactId> 136 <version>${spring.version}</version> 137 </dependency> 138 <dependency> 139 <groupId>org.springframework</groupId> 140 <artifactId>spring-tx</artifactId> 141 <version>${spring.version}</version> 142 </dependency> 143 144 145 <dependency> 146 <groupId>org.springframework.webflow</groupId> 147 <artifactId>spring-webflow</artifactId> 148 <version>2.3.3.RELEASE</version> 149 </dependency> 150 <!-- <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> 151 <version>2.5</version> </dependency> --> 152 <dependency> 153 <groupId>org.springframework.ws</groupId> 154 <artifactId>spring-ws-core</artifactId> 155 <version>2.3.0.RELEASE</version> 156 </dependency> 157 158 <dependency> 159 <groupId>com.fasterxml.jackson.core</groupId> 160 <artifactId>jackson-databind</artifactId> 161 <version>2.8.4</version> 162 </dependency> 163 <dependency> 164 <groupId>com.fasterxml.jackson.core</groupId> 165 <artifactId>jackson-core</artifactId> 166 <version>2.8.4</version> 167 </dependency> 168 <dependency> 169 <groupId>org.codehaus.jackson</groupId> 170 <artifactId>jackson-core-asl</artifactId> 171 <version>1.9.12</version> 172 </dependency> 173 <dependency> 174 <groupId>org.codehaus.jackson</groupId> 175 <artifactId>jackson-mapper-asl</artifactId> 176 <version>1.9.8</version> 177 </dependency> 178 179 180 <dependency> 181 <groupId>org.json</groupId> 182 <artifactId>json</artifactId> 183 <version>20160810</version> 184 </dependency> 185 186 <dependency> 187 <groupId>junit</groupId> 188 <artifactId>junit</artifactId> 189 <version>4.12</version> 190 <scope>test</scope> 191 </dependency> 192 <dependency> 193 <groupId>org.jmock</groupId> 194 <artifactId>jmock</artifactId> 195 <version>2.8.2</version> 196 <scope>test</scope> 197 </dependency> 198 <dependency> 199 <groupId>org.jmock</groupId> 200 <artifactId>jmock-junit4</artifactId> 201 <version>2.8.2</version> 202 <scope>test</scope> 203 </dependency> 204 <dependency> 205 <groupId>javax.servlet</groupId> 206 <artifactId>javax.servlet-api</artifactId> 207 <version>3.0.1</version> 208 <scope>provided</scope> 209 </dependency> 210 211 <!-- 日志打印jar --> 212 <dependency> 213 <groupId>log4j</groupId> 214 <artifactId>log4j</artifactId> 215 <version>1.2.16</version> 216 </dependency> 217 <dependency> 218 <groupId>ch.qos.logback</groupId> 219 <artifactId>logback-classic</artifactId> 220 <version>1.1.7</version> 221 </dependency> 222 <dependency> 223 <groupId>ch.qos.logback</groupId> 224 <artifactId>logback-core</artifactId> 225 <version>1.1.7</version> 226 </dependency> 227 <dependency> 228 <groupId>ch.qos.logback</groupId> 229 <artifactId>logback-access</artifactId> 230 <version>1.2.1</version> 231 </dependency> 232 <dependency> 233 <groupId>org.slf4j</groupId> 234 <artifactId>slf4j-api</artifactId> 235 <version>1.7.21</version> 236 </dependency> 237 <dependency> 238 <groupId>org.logback-extensions</groupId> 239 <artifactId>logback-ext-spring</artifactId> 240 <version>0.1.4</version> 241 </dependency> 242 <dependency> 243 <groupId>com.ice</groupId> 244 <artifactId>ice</artifactId> 245 <version>1.0</version> 246 </dependency> 247 </dependencies> 248 249 250 <build> 251 <resources> 252 <resource> 253 <directory>src/main/java</directory> 254 <includes> 255 <include>**/*.properties</include> 256 <include>**/*.xml</include> 257 </includes> 258 <filtering>false</filtering> 259 </resource> 260 <!-- <resource> 261 <directory>src/main/resources</directory> 262 <includes> 263 <include>**/*.properties</include> 264 <include>**/*.xml</include> 265 </includes> 266 <filtering>false</filtering> 267 </resource> --> 268 <resource> 269 <directory>src/main/resources</directory> 270 <filtering>false</filtering> 271 <excludes> 272 <exclude>resources/element-ui/**</exclude> 273 </excludes> 274 <includes> 275 <include>**</include> 276 </includes> 277 </resource> 278 <resource> 279 <directory>src/main/webapp</directory> 280 <filtering>true</filtering> 281 <includes> 282 <include>**/*.*</include> 283 </includes> 284 <targetPath>${project.build.directory}/webapp</targetPath> 285 </resource> 286 </resources> 287 288 <plugins> 289 290 <plugin> 291 <groupId>org.apache.maven.plugins</groupId> 292 <artifactId>maven-compiler-plugin</artifactId> 293 <version>3.1</version> 294 <configuration> 295 <source>1.7</source> 296 <target>1.7</target> 297 </configuration> 298 </plugin> 299 <plugin> 300 <groupId>org.apache.tomcat.maven</groupId> 301 <artifactId>tomcat7-maven-plugin</artifactId> 302 <configuration> 303 <path>/IntranetTools</path> 304 <port>9010</port> 305 <warSourceDirectory>${project.build.directory}/webapp</warSourceDirectory> 306 </configuration> 307 </plugin> 308 <plugin> 309 <groupId>org.apache.maven.plugins</groupId> 310 <artifactId>maven-war-plugin</artifactId> 311 <version>2.3</version> 312 <configuration> 313 <warName>IntranetTools</warName> 314 <webResources> 315 <resource> 316 <directory>src/main/webapp</directory> 317 <filtering>false</filtering> 318 </resource> 319 </webResources> 320 </configuration> 321 </plugin> 322 </plugins> 323 324 </build> 325 326 </project>
maven启动web项目命令:
项目右键 》 debug as 》 debug configurations 》 双击maven build 》 name输入框填写mvn-run-tomcat
》 base drectory输入框点击workspace按钮选中项目
》 Goals输入框填写 clean install -Dmaven.test.skip=true tomcat7:run
》 点击debug开始运行