创建spring项目需要从5个方面导入依赖
spring核心依赖:spring-core、spring-beans、spring-context
springdao依赖(提供JDBCTemplate:spring-jdbc、spring-tx
spring web依赖:spring-web、spring-webmvc
spring test依赖 spring-test
springAOP依赖:spring-aspects(集成AspectJ)、spring-instrument、spring-instrument-tomcat
ps:一定要有spring-jdbc.jar,这里采用的是spring-orm依赖,里面包含的有jdbc
pom.xml
根据需要进入相应依赖
<!-- 统一管理jar包版本
当前properties标签里的标签名称可以随意起,建议写一些见名知意的单词
-->
<properties>
<spring.version>5.0.2.RELEASE</spring.version>
<slf4j.version>1.6.6</slf4j.version>
<log4j.version>1.2.12</log4j.version>
<shiro.version>1.2.3</shiro.version>
<mysql.version>5.1.6</mysql.version>
<mybatis.version>3.4.5</mybatis.version>
<spring.security.version>5.0.1.RELEASE</spring.security.version>
</properties>
<!-- 锁定jar包版本 -->
<dependencyManagement>
<dependencies>
<!-- 1.Spring核心依赖 -->
<dependency>
<!-- spring上下文jar包,主要功能是注解开发-->
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<!-- spring的Ioc核心jar包-->
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<!-- spring的核心jar包-->
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- 2.Spring dao依赖 -->
<!-- spring-jdbc包括了一些如jdbcTemplate的工具类 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<!-- spring事务jar包-->
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- 3.Spring web依赖 -->
<dependency>
<!-- web表示springmvc核心jar包-->
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- 4.Spring test依赖:方便做单元测试和集成测试 -->
<dependency>
<!-- spring封装到junit测试jar包-->
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<!--下面两个jar包是mybatis的依赖jar包,mybatis核心jar包-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<!-- mybatis整合spring的核心jar包-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis.version}</version>
</dependency>
<!-- Mybatis Generator 代码生成器jar包,一般不需要 -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>${mybatis.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</dependencyManagement>
<!-- 项目依赖jar包 -->
<dependencies>
<!-- aop标签切面核心jar包-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- aspectj是配合aop完成功能的一个组件,aspectjweaver是spring的切入点表达式需要用的包-->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.8</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- 数据库mysql的jar包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!--Oracle数据库-->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
</dependency>
<!--数据库连接池jar包-->
<!--c3p0连接池jar包-->
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- 阿里巴巴的druid连接池jar包-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.9</version>
</dependency>
<!-- log start 日志的jar包 -->
<dependency>
<groupId