新建一个maven webapp工程,默认的pom.xml文件如下:
<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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>ms</groupId> <artifactId>springLearn</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>springLearn Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <finalName>springLearn</finalName> </build> </project>
常用的配置:
<properties>
<spring.version>3.1.3.RELEASE</spring.version>
<junit.version>4.10</junit.version>
<quartz.version>2.2.1</quartz.version>
<servlet.version>3.0.1</servlet.version>
<jsp.version>2.1</jsp.version>
<jstl.version>1.2</jstl.version>
<aspectj.version>1.6.10</aspectj.version>
<jdbc.groupId>mysql</jdbc.groupId>
<jdbc.artifactId>mysql-connector-java</jdbc.artifactId>
<jdbc.version>5.1.22</jdbc.version>
<log4j.version>1.2.17</log4j.version>
<commons.io.version>2.4</commons.io.version>
<slf4j.version>1.6.1</slf4j.version>
</properties>
mysql的jdbc driver的maven依赖
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.25</version> </dependency>
加slf4j
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.2</version>
</dependency>
加json:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.1</version>
<classifier>jdk15</classifier>
</dependency>
json-lib是需要区分jdk版本的,pom.xml中的配置应加上<classifier>标签,如用jdk15.
加commons-io
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
加quartz:
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3</version>
</dependency>
加apache common lang:
经常用到类似的: ReflectionToStringBuilder.toString(token, ToStringStyle.MULTI_LINE_STYLE))
要加common lang
<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.1</version> </dependency>
Apache Commons包估计是Java中使用最广发的工具包了,很多框架都依赖于这组工具包中的一部分,它提供了我们常用的一些编程需要,但是JDK没能提供的机能,最大化的减少重复代码的编写。
http://commons.apache.org/
1)Commons Lang是对JDK中java.lang包的补充,提供了各种各样的Utilities工具类,这里说说最常用的几个工具类。
版本:commons-lang3-3.1.jar
http://rensanning.iteye.com/blog/1547845