使用maven遇到的问题

在pom.xml文件中增加了htmlunit插件,传到服务器上使用mvn clean compile package -Dmaven.test.skip=true命令打包,出现错误:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.124 s
[INFO] Finished at: 2017-09-19T14:07:14+08:00
[INFO] Final Memory: 14M/171M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project XXX: Could not resolve dependencies for project com.orange:XXX:jar:0.0.1-SNAPSHOT: 
Failed to collect dependencies at net.sourceforge.htmlunit:htmlunit:jar:2.17 -> xalan:xalan:jar:2.7.2 -> xalan:serializer:jar:2.7.2 ->
xml-apis:xml-apis:jar:1.3.04: Failed to read artifact descriptor for xml-apis:xml-apis:jar:1.3.04: Could not transfer artifact
xml-apis:xml-apis:pom:1.3.04 from/to central (https://repo.maven.apache.org/maven2):
/data/repo/xml-apis/xml-apis/1.3.04/xml-apis-1.3.04.pom.part.lock (No such file or directory) -> [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/DependencyResolutionException

maven htmlunit

	<dependency>
	    <groupId>net.sourceforge.htmlunit</groupId>
	    <artifactId>htmlunit</artifactId>
	    <version>2.17</version>
	</dependency>

在我本地打包都正常,只有在服务器上报错,经过排除发现xml-apis:jar所在目录的所有者是root,而我打包使用的用户是另一个,htmlunit要下载依赖包到xml-apis:jar所在的目录,因为权限不够所以报错了,改一下所属用户和组就行了


用maven创建的java项目在启动的时候找不到spring的配置文件,是java项目,不是web项目

解决办法是在pom.xml build 中增加一个插件:

 <plugins>  
     <plugin>  
            <groupId>org.apache.maven.plugins</groupId>  
            <artifactId>maven-shade-plugin</artifactId>  
            <version>2.4.1</version>  
            <executions>  
                <execution>  
                    <phase>package</phase>  
                    <goals>  
                        <goal>shade</goal>  
                    </goals>  
                    <configuration>  
                        <transformers>  
                             <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">  
                                <mainClass>com.orange.task.StartMain</mainClass>  
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">  
                                <resource>META-INF/spring.handlers</resource>  
                            </transformer>  
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">  
                                <resource>META-INF/spring.schemas</resource>  
                            </transformer>  
                        </transformers>  
                    </configuration>  
                </execution>  
            </executions>  
        </plugin>  
 </plugins>  



maven打包编译
mvn clean compile package -Dmaven.test.skip=true


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值