Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
Maven
- A software profject management & comprehension tool ( not Pacakge Management ! )
- based on a POM (project object model)
- including project's build, reporting & documentation
References
- maven.apache.org
- Book :《 Maven 实战 》( Maven 3 in Action 中文版 )
- Config file :
.m2/settings.xml
- One of mirrors : https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent/2.0.1.RELEASE
- IntelliJ:
⌘ n
in filepom.xml
>> choosedependency
- Then, enable
Maven Auto Import
Topbar
(taskbar) >>Code
>>Generate…
References
- Maven - Introduction to the Dependency Mechanism
- Difference between maven scope compile and provided for JAR packaging - Stack Overflow
- Difference between maven compile and provided scope (Other Build Tools forum at Coderanch)
Differ provided
from compile
- dependencies are not transitive (as you mentioned)
- provided scope is only available on the compilation and test classpath, whereas compile scope is available in all classpaths.
- provided dependencies are not packaged
Compile means that you need the JAR for compiling and running the app. For a web application, as an example, the JAR will be placed in the WEB-INF/lib directory.
Provided means that you need the JAR for compiling, but at run time there is already a JAR provided by the environment so you don't need it packaged with your app. For a web app, this means that the JAR file will not be placed into the WEB-INF/lib directory.
For a web app, if the app server already provides the JAR (or its functionality), then use "provided" otherwise use "compile".
References
- maven依赖jar包时版本冲突的解决 : https://blog.csdn.net/sinat_39789638/article/details/78005945
References
- How to add local jar files to a Maven project? - Stack Overflow : https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project
mvn install:install-file \
-Dfile=<path-to-file> \
-DgroupId=<group-id> \
-DartifactId=<artifact-id> \
-Dversion=<version> \
-Dpackaging=<packaging> \
-DgeneratePom=true
# e.g.
mvn install:install-file \
-Dfile=icehe-sdk-1.0.0-20200604.105923-1.jar \
-DgroupId=xyz.icehe \
-DartifactId=icehe-sdk \
-Dversion=1.0.0-SNAPSHOT \
-Dpackaging=jar \
-DgeneratePom=true
References
- Frequently Asked Questions
- I don't want to deploy one of the artifacts in my multi-module build. Can I skip deployment?
pom.xml
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
试错经验
- 子模块不要写变量, 显式写明 version
- plugin 写 deply
<configuration><deploy>true</deploy></configuration>
结果跳过了部署…… - 依赖排错命令 mvn dependency:list/tree/analyze