1. 程式人生 > >從svn中check out maven專案 所遇到的一系列問題:

從svn中check out maven專案 所遇到的一系列問題:

1、maven專案從svn匯出後,不是maven結構:

右鍵專案-->configure--->convert  to maven project 

2、maven專案check out後,java檔案是空心J,不是實心:

原因: 
eclipse認為檢出內容為資原始檔,而不是專案。 
解決辦法: 
編輯專案下的.project檔案, 
(1)在<buildCommand>中加<name>org.eclipse.jdt.core.javabuilder</name> 
(2)<natures>中加<nature>org.eclipse.jdt.core.javanature</nature> 


3、tomcat中不能識別剛檢出的web專案:

右鍵專案--->config->convert to fat project

右鍵專案--->config->convert to plug_in

4、pom檔案總是有錯誤提示,紅‘X’號,提示有錯誤。

setting.xml檔案是否配置正確。(E:\apache-maven-3.3.1\conf\setting.xml)

檢視setting.xml的路徑:windows-->properties-->maven-->user settings -->看右半部分內容。

5、新匯出的專案總沒有Maven Dependencies 和JRE System Library :

右鍵專案---》properties---》Deployment Assembly --->add --->maven Dependencies

後來再上網搜尋,找到了解決辦法:

找自己出錯專案的.classpath檔案,開啟,ctrl+f,找是否有以下檔案,如果沒有在末尾加進去,再refresh專案即可:

<span style="font-size:14px;"><classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
		</attributes>
</classpathentry></span>

新增後我的.classpath檔案是這樣的:

<span style="font-size:14px;"><?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src/main/java"/>
	<classpathentry kind="src" path="src/main/resources"/>
	<classpathentry kind="src" path="src/extend/java"/>
	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0 (2)">
		<attributes>
			<attribute name="owner.project.facets" value="jst.web"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7">
		<attributes>
			<attribute name="owner.project.facets" value="java"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="output" path="build/classes"/>
</classpath></span>

右鍵專案---》build path -->configre build path --->右面視窗Libraries -->add Library--->jar system library 

6、在tomcat中啟動maven專案,提示找不到類:嚴重: Error configuring application listener of class org.springframework.web.context.request.RequestContextListener
java.lang.ClassNotFoundException: org.springframework.web.context.request.RequestContextListener

(1)普通的web專案:http://www.cnblogs.com/zhouyalei/archive/2011/11/30/2268606.html

(2)maven專案:http://www.yihaomen.com/article/java/471.htm

右鍵專案---》properties-->Deployment Assembly --->

1、右鍵單擊工程專案 ->點選 properties
2. 選擇 Deployment Assembly
3. 點選 Add -> Java Build Path Entries -> Next
4. 選擇 Maven Dependencies -> Finish -> Apply -> OK
5. Clean project and server. 重啟server

8、新建出的專案轉換成maven專案後,目錄結構不是標準的maven專案:


選中專案,在右上角”倒三角“的地方,Package Presentation --->Hierarchical,此時目錄顯示為標準包結構。