Maven配置Spring+SpringMVC+MyBatis(3.2.2)Pom
配置原则:
利用依赖,将所需的jar包加载到project中。
- 先依赖主要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包自己主动依赖到project中。
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包,自己主动依赖到project中。
以下是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>
使用Intellij IDEA 查看POM依赖视图:
- View --> 选中 Tools Buttons
- 点击左側的Struture视图。
- 在Project右键 --> Diagrams --> Show Dependencies
所有结束。
如有疑问,能够留言哦!
时间: 2024-10-25 20:43:02