利用依赖,将所需的jar包载入到工程中。
先依赖主要jar包
Spring + Spring MVC + MyBatis + database
再依赖次要jar包
C3p0连接池,log4j,Junit
外围jar包
POI jFreeCharts jxl
例子:
通常只使用Spring时,将spring-context
依赖到pom中。
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${org.springframework.version}</version> </dependency>
效果图如下:
spring-context
会将一下jar,自动依赖过来。
commons-logging:1.1.1 spring-aop:3.2.2.RELEASE spring-beans:3.2.2.RELEASE spring-context:3.2.2.RELEASE spring-core:3.2.2.RELEASE spring-expression:3.2.2.RELEASE
由于,这个项目使用Spring+SpringMVC+MyBatis作为架构,其核心就SpringMVC。
所以首先依赖spring-webmvc
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${org.springframework.version}</version> </dependency>
同理,spring-webmvc
会将以下jar包自动依赖到工程中。
commons-logging:1.1.1 spring-aop:3.2.2.RELEASE spring-beans:3.2.2.RELEASE spring-context:3.2.2.RELEASE spring-core:3.2.2.RELEASE spring-expression:3.2.2.RELEASE spring-web:3.2.2.RELEASE spring-webmvc:3.2.2.RELEASE
使用Spring时,缺少不了事务的存在,而事务是在spring-orm
中,将spring-orm
依赖到项目中
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${org.springframework.version}</version> </dependency>
同理,spring-orm
会将一下jar包,自动依赖到工程中。
下面是Spring + SpringMVC + MyBatis + POI 的所有POM.xml文件信息。
<properties> <org.springframework.version>3.2.2.RELEASE</org.springframework.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${org.springframework.version}</version> <type>jar</type> <scope>test</scope> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.8.2</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.2</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> <version>0.9.1.2</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.31</version> </dependency> <dependency> <!--会级联加载:log4j --> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.9</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.9</version> </dependency> <dependency> <groupId>jfree</groupId> <artifactId>jfreechart</artifactId> <version>1.0.13</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.9</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.0.1</version> </dependency> <dependency> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>jstl-api</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.glassfish.web</groupId> <artifactId>jstl-impl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>jexcelapi</groupId> <artifactId>jxl</artifactId> <version>2.4.2</version> </dependency> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-servlet-api</artifactId> <version>7.0.8</version> <scope>provided</scope> </dependency>
全部结束。如有疑问,可以留言哦!