Maven usage notes (continuous improvement)

Common commands:
tomcat:run tomcat run project
clean deploy upload maven warehouse

clean package

clean install install jar

-Xms1024m -Xmx2024m -XX:MaxPermSize=256m

**************************************************** **************************************************** ************************
settings.xml configuration:
download maven file
address : https://maven.apache.org/ find the download link
windows:
http ://mirror.bit.edu.cn/apache/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.zip


linux:
wget http://mirror.bit.edu.cn /apache/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.tar.gz 
apache-maven-3.5.3-bin.tar.gz


Extract:
tar -zxvf apache-maven- 3.5.3-bin.tar.gz


modify settings.xml:


1, Local repository address:
<localRepository>E:\work_soft\maven\repository</localRepository>


2, Remote repository authentication
Most public remote repositories do not require authentication It can be accessed directly, but we often set up our own Maven remote warehouse in our usual development. For security reasons,
We need to provide authentication information to access such a remote repository. Configuring authentication information is different from configuring remote warehouses. Remote warehouses can be configured directly in pom.xml,
but authentication information must be configured in settings.xml file. This is because the pom is often submitted to the code repository for access by all members,
while settings.xml generally only exists locally. Therefore, it is more secure to configure authentication information in settings.xml.
<servers>
<server>
      <id>junlenet</id>
      <username>admin</username>
      <password>junlenet_2020</password>
    </server>
</servers>
In the above code, we configure a remote repository with an id of releases Certification Information. Maven uses the servers element in the settings.xml file and its sub-element server to configure repository authentication information.
The authentication user name is admin, and the authentication password is admin123. The key here is the id element. The id of the server element in settings.xml must be exactly the same
as the . It is this id that links the authentication information to the repository configuration.




3. Configure the default jdk version: (the default jdk version after creating a new maven project in eclipse)
Add in the profiles node:
<!-- Configure the default JDK of the maven project to be 1.

<id>dev-jdk1.7</id>
<activation>
 <jdk>1.7</jdk>
 <activeByDefault>true</activeByDefault>
</activation>
<properties>
 <maven.compiler.source>1.7</maven.compiler.source>
 <maven.compiler.target>1.7</maven.compiler.target>
 <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
</profile> 4,配置远程仓库地址: <profile> <id>osc</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>osc</id> <url>http://maven.oschina.net/content/groups/public/</url> </repository>












<repository>
<id>osc_thirdparty</id>
<url>http://maven.oschina.net/content/repositories/thirdparty/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>osc</id>
<url>http://maven.oschina.net/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>




****************************************************************************************************************************
1,clean install 错误信息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project soa-user-api: Compilation failure: Compilation failure:
[ERROR] /D:/dubbo/soa-parent/soa-user/soa-user-api/src/test/java/com/junlenet/soa/user/api/AppTest.java:[3,23] package junit.framework does not exist
[ERROR] /D:/dubbo/soa-parent/soa-user/soa-user-api/src/test/java/com/junlenet/soa/user/api/AppTest.java:[4 ,23] Package junit.framework does not exist
[ERROR] /D:/dubbo/soa-parent/soa-user/soa-user-api/src/test/java/com/junlenet/soa/user/api/AppTest .java:[5,23] Package junit.framework does not exist
[ERROR] /D:/dubbo/soa-parent/soa-user/soa-user-api/src/test/java/com/junlenet/soa/ user/api/AppTest.java:[11,13] Symbol not found
[ERROR] Symbol: class TestCase
[ERROR] /D:/dubbo/soa-parent/soa-user/soa-user-api/src/test /java/com/junlenet/soa/user/api/AppTest.java:[26,19] Symbol
[ERROR] not found symbol: class Test
[ERROR] location: class com.junlenet.soa.user.api.AppTest
[ERROR] /D:/dubbo/soa-parent/soa-user/soa-user-api/src/test/java/com/junlenet/soa/user/api/AppTest.java:[28,20] not found to symbol
[ERROR] symbol: class TestSuite
[ERROR] location: class com.junlenet.soa.user.api.AppTest
[ERROR] /D:/dubbo/soa-parent/soa-user/soa-user-api/src /test/java/com/junlenet/soa/user/api/AppTest.java:[36,9] Symbol not found
[ERROR] Symbol: method assertTrue(boolean)
[ERROR] Location: class com.junlenet.soa. user.api.AppTest
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the - X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :soa-user-api


解决方案:
clean install -Dmaven.test.skip=true


****************************************************************************************************************************

Solve the problem that after maven fails to download jar, it cannot be downloaded. This script is to clear the download failure first. Then modify the pom.xml and save it to download it again.     

Operation: Create a new cleanup.bat file, copy the following content into it, save it, and double-click to run it.

@echo off  
rem create by sunhao([email protected])  
rem crazy coder  
    
rem -- write your repository path here  
set REPOSITORY_PATH=E:\work_soft\maven\repository
rem -- searching...  
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (  
    del /s /q %%i  
)  
rem search finished  

pause  

****************************************************************************************************************************

org.apache.maven.archiver.MavenArchiver.getManifest (org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration) 

Solution: Help——>Install New SoftWare -->> add 

MavenArchive

https://otto.takari.io/content/sites/m2e.extras/m2eclipse-mavenarchiver/0.17.2/N/LATEST/


After installation, restart, and then execute maven-update project .

****************************************************************************************************************************



Guess you like

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