上QQ阅读APP看书,第一时间看更新
Adding Log4j 2.9.1 to POM dependency
Once the dependency is added and the project is updated on your IDE, the corresponding library will be copied into \.m2\repository:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.9.1</version>
</dependency>
The preceding dependency, log4j-core, will be added under POM. In this dependency, you can see groupId, artifactId, and version explained as follows:
- groupId is used to make the JAR/WAR file unique across all projects. As it will be used globally, Maven recommends that the package names follow the same rules as that of domain names with subgroups. A sample groupId is com.google.appengine. However, some third-party dependencies don't follow the groupId package-naming policy. Check the following sample:
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
</dependency>
- artifactId is just the name of the JAR/WAR file without the extension.
- version comes with number to show the JAR file version. Some JAR files come with extra information, such as RELEASE, for example, 3.1.4.RELEASE.
The following code will download the spring-security-web library 3.1.4 JAR file to the repository location:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
The Log4j-core files (in Windows) will appear as follows:
Sometimes, you may see the .jar file missing when you update the project on IDE. In such cases, delete the whole folder (in our case log4j-core folder) and update them once again. In order to update the missing JAR file, after you delete the folder, just update your IDE (STS /Eclipse in our case) by right clicking the project and select Maven | Update Project . Finally, make sure you have the .jar file available under the folder.
Sample repositories in .m2\repository should appear as follows:
When you update a project (in Eclipse or any other IDE), it will get the JAR and related files from a remote Maven repository to your system's central repository.