Spring相关依赖
Posted 玩葫芦的卷心菜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring相关依赖相关的知识,希望对你有一定的参考价值。
文章目录
1、Maven静态资源过滤问题
<!--在Build中配置Resources, 来防止我们资源导出失败的问题-->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
2、使用properties进行版本控制
方便版本兼容问题而导致更改版本
比如你spring用的5.3.6,但是太新了,需要改为5.2,那么所有Spring都要改一遍,那就浪费时间
而使用properties就只要改自定义版本就行了
<properties>
<spring.version>5.3.6</spring.version>
<mybatis.version>3.5.6</mybatis.version>
<mybatis.spring.version>2.0.1</mybatis.spring.version>
</properties>
2、核心依赖(缺少核心依赖 Spring就不能运行):
spring-core:核心
spring-context:读取全文
srping-beans:管理bean
spring-expression
commons-logging:日志
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>$spring.version</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>$spring.version</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>$spring.version</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>$spring.version</version>
</dependency>
你会发现这些依赖 包含着其他依赖,有些依赖就不用导了
3、AOP(面向切面)
需要aop依赖和aspectjweaver配合进行
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>$spring.version</version>
</dependency>
<!--切面-->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.13</version>
</dependency>
4、SpringData(+jdbc)
spring-jdbc:spring自带封装的jdbc
spring-tx:事务依赖Tranaction
spring-orm:spring整合数据层框架所需依赖
<!--mysql连接驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>
<!--spring自己封装的jdbc-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>$spring.version</version>
</dependency>
<!--事务依赖 Transaction -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>$spring.version</version>
</dependency>
<!--spring整合数据层框架所需依赖 orm:持久化-->
<dependency>
<groupId>springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>1.2.6</version>
</dependency>
5、整合Junit
<!--整合junit-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.6</version>
<scope>$spring.version</scope>
</dependency>
6、整合Mybatis
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>$mybatis.spring.version</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>$mybatis.version</version>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
7、整合mvc
spring-web和spring-webmvc不太一样,导spring-webmvc就行
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<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>
以上是关于Spring相关依赖的主要内容,如果未能解决你的问题,请参考以下文章