Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common mistakes in maven

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what are the common mistakes in maven". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the common mistakes in maven.

1) the value of the dependent usage range in the pom file: compile default value. This dependency can be used both at compile and run time. The dependency is packaged. The provided dependency is available at compile time but not at run time, and at run time the program can use the dependency provided by the container if it is provided by the container. The dependency will not be packaged. The runtime dependency is not available at compile time and can be used at run time. Test is only available at test compilation and test run time. For example: org.springframework.boot spring-boot-starter-tomcat provided 2) enter war package: 1 > enter the project directory, press and hold the shift key, and then right-click to select "Open Command window here". 2 > execute commands on the command line: mvn clean package-Dmaven.test.skip=true-P env-prod description: when compiling and packaging with mvn package, maven will execute JUnit test cases under src/test/java, so we need to skip the process of executing test cases when packaging. Parameter:-Dmaven.test.skip=true means that the test case is not executed and the test case class is not compiled. -P env-prod specifies the configuration file to be used when packaging, that is, the id attribute of the tag in the pom file. 3 > in the target folder of the project directory, we can see the war package we just typed.

Common errors:

[error 1] org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [FATAL] Non-resolvable parent POM: Could not find artifact com.jxn.parent:jxn-parent:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 4, column 10 parsing: the parent POM file cannot be parsed. Note: when set, a relative path is required to find the pom.xml of the parent project, and if not, the default parent project pom.xml is in the parent appendix of the pom.xml. If not, it will be found in the local and remote maven repositories based on groupId and artifactId. Solution: method 1: specify the correct parent pom path by.. / pom.xml, default to.. / pom.xml method 2: install the parent project to the local repository: select the parent project, right-select Run As-- Maven install [error 2] Project build error Analysis: this package is missing in the updated jar package Reload: solution: 1) select the project, first project- > clean the following 2) select the project, Debug AS- > maven clean 3) load the jar,Debug AS- > maven INSTALL in pom [error 3] the pom.xml file checked out from SVN reported an error. Could not calculate build plan:xxx or its dependencies could not be resolved: Failed to read artifact descriptor for xxx.jar or Cannot resolve symbol 'ClassName' (unable to parse a class) error. Analysis: due to network reasons, the Maven dependency was not downloaded completely, and the * .lastUpdate file appeared, resulting in the inability to re-download the complete dependency. Solution: 1) delete all files ending in .lastUpdate a) switch to maven's local warehouse (D:\ repository) b) open cmd command line in the current directory c) execute the command: for / r% I in (* .lastUpdated) do del% I 2) execute Maven Update on the project to this point I believe that you have a deeper understanding of "what are the common mistakes in maven?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report