maven常见问题汇总专题
- 格式:pdf
- 大小:681.58 KB
- 文档页数:9
maven常见问题汇总专题
child module ….pom.xml does not exist
a.注意module的名称是否正确,有时候命名问题会导致找不到项⽬的
b.注意⼀开始项⽬命名的规则问题注意⼀开始项⽬命名的规则问题
报错信息:
[INFO]
[INFO] --- maven-assembly-plugin:2.6:single (app) @ api ---
[INFO] Reading assembly descriptor: src/assembly/assembly.xml
[ERROR] OS=Windows and the assembly descriptor contains a *nix-specific root-relative-reference (starting with slash) /bin
[ERROR] OS=Windows and the assembly descriptor contains a *nix-specific root-relative-reference (starting with slash) /lib
[INFO] Building tar: F:\project\workspace\com\api\target\com-app.tar.gz
[ERROR] OS=Windows and the assembly descriptor contains a *nix-specific root-relative-reference (starting with slash) /bin
[ERROR] OS=Windows and the assembly descriptor contains a *nix-specific root-relative-reference (starting with slash) /lib
[INFO] Building zip: F:\project\workspace\com\api\target\com-app.zip
解决办法:
The working solution is to specify the empty outputDirectory:
${basedir}/src/main/resources
有错误产⽣的assembly.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
app
tar.gz
zip
false
${project.build.directory}/bin
/bin
${project.build.directory}
*.jar
*sources.jar
/lib
https://stackoverflow.com/questions/28500401/maven-assembly-plugin-warning-the-assembly-descriptor-contains-a-filesystem-roo
使⽤maven-compiler-plugin 时
POM⽂件如下:
maven-compiler-plugin
1.6
1.6
UTF-8
[WARNING] Some problems were encountered while building the effective model for com.xxx.xxx:xxxx:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 72, column 12
修改后如下,OK了
org.apache.maven.plugins
maven-compiler-plugin
3.6.1
1.6
1.6
Configuring Your Compiler Plugin
Since the Compiler Plugin executes automatically during their phases, you don't have to put executions unlike many other plugins. However, you should specify the version of
the Compiler Plugin.
...
org.apache.maven.plugins
maven-compiler-plugin
3.6.1
...
http://maven.apache.org/plugins/maven-compiler-plugin/usage.html
maven install⽣成最终的构件包xxx-1.0.0.war(xxx-1.0.0.jar)后,
在其下的WEB-INF/lib(xxx-1.0.0.jar\BOOT-INF\lib)中,会包含我们被标注为scope=compile的构件的jar包,
⽽不会包含我们被标注为scope=provided的构件的jar包。这也避免了此类构件当部署到⽬标容器后产⽣包依赖冲突。
依赖范围控制哪些依赖在哪些classpath 中可⽤,哪些依赖包含在⼀个应⽤中。让我们详细看⼀下每⼀种范围:
compile (编译范围)
compile是默认的范围;如果没有提供⼀个范围,那该依赖的范围就是编译范围。编译范围依赖在所有的classpath 中可⽤,同时它们也会被打包。
provided (已提供范围)
provided 依赖只有在当JDK 或者⼀个容器已提供该依赖之后才使⽤。例如, 如果你开发了⼀个web 应⽤,你可能在编译 classpath 中需要可⽤的Servlet API 来编译⼀个
servlet,但是你不会想要在打包好的WAR 中包含这个Servlet API;这个Servlet API JAR 由你的应⽤服务器或者servlet 容器提供。已提供范围的依赖在编译classpath (不是运
⾏时)可⽤。它们不是传递性的,也不会被打包。
runtime (运⾏时范围)
runtime 依赖在运⾏和测试系统的时候需要,但在编译的时候不需要。⽐如,你可能在编译的时候只需要JDBC API JAR,⽽只有在运⾏的时候才需要JDBC
驱动实现。
test (测试范围)
test范围依赖 在⼀般的编译和运⾏时都不需要,它们只有在测试编译和测试运⾏阶段可⽤。
system (系统范围)
system范围依赖与provided 类似,但是你必须显式的提供⼀个对于本地系统中JAR ⽂件的路径。这么做是为了允许基于本地对象编译,⽽这些对象是系统类库的⼀部分。这样的
构件应该是⼀直可⽤的,Maven 也不会在仓库中去寻找它。如果你将⼀个依赖范围设置成系统范围,你必须同时提供⼀个 systemPath 元素。注意该范围是不推荐使⽤的(你应
该⼀直尽量去从公共或定制的 Maven 仓库中引⽤依赖)。
package阶段得到的是build⽬录下编译后的类包(jar),
install是把这个包和⼀些maven的元信息(⽐如pom.xml)复制到本地仓库,
assembly⼀般是把build结果和⼀些资源⽂件组成⼀个可以对外发布的包(zip包等),部署会⽤到。
Non-resolvable parent POM: Could not find artifact com.tangcheng:dubbo:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at no local POM @ line 14, column 13 -> [Help 2]
原因:
开始新的多个模块的项⽬时,其中的parent项⽬要先install⼀次。
就是新建了⽗项⽬后,⼀定要运⾏mvn install命令,才能建⽴⼦项⽬
解决办法:把pom中的modules删除,然后执⾏mvn install。然后ctrl+z把刚才删除的信息还原。
1、
Failure to transfer org.apache.poi:poi-ooxml-schemas:jar:3.10.1 from http://repo.maven.apache.org/maven2 was cached in the local repository,
resolution will not be reattempted until the update interval of central has elapsed or updates are forced.
Original error: Could not transfer artifact org.apache.poi:poi-ooxml-schemas:jar:3.10.1 from/to central (http://repo.maven.apache.org/maven2):
Connection reset。
这句话的意思是: 对于这个包从maven中⼼传输到本地仓库失败,决定不会重新尝试下载jar包,直到mavne再改更新索引,或强制更新。