Classifier property in dependency

The classifier element is used to help define some subsidiary components of the component output. The auxiliary components correspond to the main components. For example, the main component is kimi-app-2.0.0.jar. The project may also be generated by using some plugins such as kimi-app-2.0.0-javadoc.jar and kimi-app-2.0.0 -sources.jar such two dependent components. At this time, javadoc and sources are the classifiers of these two subsidiary components, so that the subsidiary components have their own unique coordinates.

Note:

The classifer of the project cannot be defined directly, because the auxiliary components are not generated directly by the project by default, but are generated with the help of additional plugins.

The purpose of the classifier is to:

1. When maven download javadoc / sources shelf package

2. When introducing dependencies, usually we only need to:

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.1.2.RELEASE</version> 
        </dependency>

But some racks are quite special:

For example, JSON-lib, I used sonatype's jar search engine to search and found that JSON-lib's jar provides two versions of the SDK, as shown in the figure:

 

                                          

At this time, you must use the classifier attribute to specify:

copy code
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier> 
        </dependency>
copy code

If the classifier is not defined, maven will report an error saying that the jar file cannot be found.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326271703&siteId=291194637