在Eclipse Create一個maven-archetype-webapp專案時,丟出警告訊息,之後還是產出Project目錄。maven-archtype-webapp站台可能怪怪的,重點不在此。之前Create struts2-archetype-starter成功後,Project的圖示有M和J的字母,代表同時為Maven Project和Java Project。而maven-archtype-webapp產出的Project圖示只有M,因此我想去Create一個Package或Class或Source Folder都失敗,失敗訊息如標題所示:Source folder is not a java project。
每個Project目錄下至少有個.project檔,而maven-archtype-webapp的.project檔目錄內容很少,節錄如下:
<buildSpec> <buildCommand> <name>org.maven.ide.eclipse.maven2Builder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.maven.ide.eclipse.maven2Nature</nature> </natures> |
相形之下,struts2-archetype-starter的.project檔,其buildCommmand和natures內容就不少:
<buildSpec> <buildCommand> <name>org.eclipse.wst.jsdt.core.javascriptValidator</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.wst.common.project.facet.core.builder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.wst.validation.validationbuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.maven.ide.eclipse.maven2Builder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.maven.ide.eclipse.maven2Nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.jsdt.core.jsNature</nature> </natures> |
標粗黑體字應該就是Java Project的設定了,不止如此,同目錄下還有個.classpath檔,標出哪些folder是source folder,內容如下:
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" output="target/classes" path="src/main/java"/> <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> <classpathentry kind="src" output="target/test-classes" path="src/test/java"/> <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <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.j2ee.internal.module.container"/> <classpathentry kind="output" path="target/classes"/> </classpath> |
所以後來解決方式,就是把struts2-archetype-starter的Project目錄下.project和.classpath檔蓋到maven-archtype-webapp的Project目錄下,再Refresh,就變成兼具Maven和Java的Project。
留言列表