Why is it not necessary to write version number < version > when writing dependencies < dependencies > in maven configuration of some spring projects

Keywords: Junit Spring JSP Maven

Why do you not need to write version number when writing dependency in maven configuration of some spring projects

I. The first situation:

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

Like above

Generally, this happens because.

  1. Inherited the configuration of spring boot. The advantage of introducing spring boot starter parent here is that you do not need to declare the version number when adding the initiator!
  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.3.RELEASE</version>
    </parent>

**

Second situation

**

 <dependencies>
        <!-- junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <!-- The jar Package retention to test -->
            <scope>test</scope>
        </dependency>
        <!-- jsp-api,servlet-api,el -->
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jsp-api</artifactId>
            <version>${jsp.api.version}</version>
            <!-- The jar Final package Web Container supply -->
            <scope>provided</scope>
        </dependency>
    </dependencies>

That's because there's a property file in the top of the maven file

<properties>
        <junit.version>4.11</junit.version>
        <jsp.api.version>8.5.5</jsp.api.version>
    </properties>

Add: when making a big project, we must pay attention to the compatibility between jar packages. Too many jar packages are introduced. If they are not compatible, they will always report errors, which are also the most difficult to find.

Posted by sherri on Sun, 24 Nov 2019 14:24:27 -0800