强调:以下配置是在父pom中写的,如果有子pom文件还要再次导入这些依赖包但是不需要写版本了

1.idea自动生成的部分

2.SpringMVC的依赖包

 1 <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
 2 <dependency>
 3     <groupId>org.springframework</groupId>
 4     <artifactId>spring-webmvc</artifactId>
 5     <version>5.1.7.RELEASE</version>
 6 </dependency>
 8 <!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
 9 <dependency>
10     <groupId>org.springframework</groupId>
11     <artifactId>spring-web</artifactId>
12     <version>5.1.7.RELEASE</version>
13 </dependency>

3.要想使用spring肯定要导入相应的依赖库,具体依赖库如下:

 1        <properties>
            <spring.version>5.1.7.RELEASE</spring.version><!--配置spring的版本,写在properties属性中-->
         </properties>
      <!--下面配置spring的核心依赖包-->
         <dependency>
 2                 <groupId>org.springframework</groupId>
 3                 <artifactId>spring-context</artifactId>
 4                 <version>${spring.version}</version>
 5             </dependency>
 6             <dependency>
 7                 <groupId>org.springframework</groupId>
 8                 <artifactId>spring-core</artifactId>
 9                 <version>${spring.version}</version>
10             </dependency>
11             <dependency>
12                 <groupId>org.springframework</groupId>
13                 <artifactId>spring-beans</artifactId>
14                 <version>${spring.version}</version>
15             </dependency>
16             <dependency>
17                 <groupId>org.springframework</groupId>
18                 <artifactId>spring-context-support</artifactId>
19                 <version>${spring.version}</version>
20             </dependency>

4.maven编译插件

        
       <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <maven.compiler.source>1.8</maven.compiler.source><!--采用jdk1.8-->

          <maven.compiler.target>1.8</maven.compiler.target><!--采用jdk1.8-->

          <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>

        </properties>

       <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>

5.测试支持依赖包

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>5.1.7.RELEASE</version>
    <scope>test</scope>
</dependency>

6.新版本的jdk不支持@Resource,在新版本中如果想使用此注解就需要引用下列配置

1 <!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
2 <dependency>
3     <groupId>javax.annotation</groupId>
4     <artifactId>javax.annotation-api</artifactId>
5     <version>1.3.2</version>
6 </dependency>

7.引入aop切面编程依赖包和AspectJ表达式(想使用aop切面编程,除了需要导入下列依赖包之外,还要在spring-base.xml文件中配置相关参数,具体配置见spring-base.xml)

 1         <dependency><!--引入AspectJ表达式-->
 2                 <groupId>org.springframework</groupId>
 3                 <artifactId>spring-aspects</artifactId>
 4                 <version>${spring.version}</version>
 5             </dependency>
 6             <dependency><!--引入aop依赖包-->
 7                 <groupId>org.springframework</groupId>
 8                 <artifactId>spring-aop</artifactId>
 9                 <version>${spring.version}</version>
10             </dependency>

8.lettuce的依赖包(redis的驱动)

1 <!-- https://mvnrepository.com/artifact/io.lettuce/lettuce-core -->
2 <dependency>
3     <groupId>io.lettuce</groupId>
4     <artifactId>lettuce-core</artifactId>
5     <version>5.1.7.RELEASE</version>
6 </dependency>

9.maven打包插件

 1         <plugin>
 2                 <groupId>org.apache.maven.plugins</groupId>
 3                 <artifactId>maven-source-plugin</artifactId>
 4                 <version>3.0.1</version>
 5                 <executions>                <!-- 进行执行配置 -->
 6                     <execution>
 7                         <id>sources</id>     <!-- 设置执行的id编号 -->
 8                         <goals>
 9                             <goal>jar</goal>    <!-- 打包生成的类型 -->
10                         </goals>
11                     </execution>
12                 </executions>
13             </plugin>

10.maven生成文档插件

 1         <plugin>
 2                 <groupId>org.apache.maven.plugins</groupId>
 3                 <artifactId>maven-javadoc-plugin</artifactId>
 4                 <version>3.1.0</version>
 5                 <configuration> <!-- 配置编码 -->
 6                     <encoding>${project.build.sourceEncoding}</encoding>
 7                     <failOnError>false</failOnError>    <!-- 不关心不严谨的注释 -->
 8                 </configuration>
 9                 <executions>    <!-- 进行执行配置 -->
10                     <execution>
11                         <id>javadocs</id>   <!-- 生成文件的标记 -->
12                         <goals>
13                             <goal>jar</goal>    <!-- 生成文件的类型 -->
14                         </goals>
15                     </execution>
16                 </executions>
17             </plugin>

11.maven跳过测试插件

        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <skipTests>true</skipTests> <!-- 跳过测试 -->
                </configuration>
            </plugin>

12.打包生成的名称(此标签与plugins同级,写在build标签中)

<finalName>redis</finalName>         <!-- 表示打包生成的名称 -->

13.配置资源文件

      <properties>

        <profiles.dir>src/main/profiles</profiles.dir> <!-- 定义profiles父路径 -->
        <resources.dir>src/main/resources</resources.dir> <!-- 定义resources父路径 -->

     </properties>
     <resources><!--resources标签与plugins标签同级别,写在build标签中--> <resource> <!-- 此处的属性是profile中统一定义的路径的名称,不同的配置文件有不同的子目录 --> <directory>${profile.dir}</directory> <filtering>false</filtering> </resource> <resource> <directory>${resources.dir}</directory> <filtering>false</filtering> </resource> </resources>

14.Redis数据库连接池依赖包

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-pool2</artifactId>
    <version>2.6.2</version>
</dependency>

15.SpringData组件包(Spring内部连接数据库的组件,一定要记住SpringData依赖于Spring开发环境,SpringData组件包下面有很多种数据库,用的时候根据不同的数据库导入不同的包)

<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-redis -->
<dependency><!--对应redis数据库的依赖包-->
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-redis</artifactId>
    <version>2.1.9.RELEASE</version>
</dependency>

16.json依赖包

        <jackson.version>2.9.9</jackson.version><!--jackson依赖包-->
        <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>${jackson.version}</version> </dependency>

17.发布订阅模式依赖包(第一种方法lettuce程序实现发布订阅,引入reactor-core组件包)

<!-- https://mvnrepository.com/artifact/io.projectreactor/reactor-core -->
<dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-core</artifactId>
    <version>3.2.10.RELEASE</version>
</dependency>

18.发布订阅模式(第二种方法是用SpringDataRedis实现发布订阅模式,此方法有两种机制,具体见发布订阅模式笔记)

19.EL表达式的包

1 <!-- https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/jstl -->
2             <dependency>
3                 <groupId>javax.servlet.jsp.jstl</groupId>
4                 <artifactId>jstl</artifactId>
5                 <version>1.2</version>
6             </dependency>

20.上传组件的依赖包(需要引入两个依赖包),引入完成依赖包之后需要在spring-mvc.xml配置文件中进行上传组件的设置

1 <!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
2 <dependency>
3     <groupId>commons-fileupload</groupId>
4     <artifactId>commons-fileupload</artifactId>
5     <version>1.4</version>
6 </dependency>

  <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
  <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.6</version>
  </dependency>

21.日志依赖包

1 <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl -->
2 <dependency>
3     <groupId>org.apache.logging.log4j</groupId>
4     <artifactId>log4j-slf4j-impl</artifactId>
5     <version>2.11.2</version>
6 </dependency>

22.mybatis依赖包

1 <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
2 <dependency><!--mysql数据库驱动-->
3     <groupId>mysql</groupId>
4     <artifactId>mysql-connector-java</artifactId>
5     <version>5.1.47</version>
6 </dependency>

  <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
  <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.5.1</version>
  </dependency>

优质内容筛选与推荐>>
1、编程实现>ASP.NET 3.5开发范例精讲精析>探讨gridview控件
2、Linux编程之给你的程序开后门
3、RegisterWaitForSingleObject的使用
4、大数据计算:如何仅用1.5KB内存为十亿对象计数
5、自定义封装Logger demo 小测试


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn