使用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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章