Idea的gradle項目導入到eclipse中


*

背景:在eclipse中,先svn檢出項目,發現項目沒有grable的圖標,於是刪除項目(不刪除實際文件夾),然后import- gradle project,導入后項目會顯示gradle的圖標了,

然后先build path,添加jre 和 tomcat,這個做好后,還有很多其他問題:

1,右鍵 gradle --> reflesh gradle project,出錯

java cannot nest inside library。。。。

*****

改build.gradle文件,刪除下面幾句:

 

apply plugin: 'idea'
apply plugin: 'war'

webAppDirName = 'WebContent'

2,現在可以成功reflesh gradle project,點擊右下邊

可以成功build

然后想把項目add 到tomcat中,結果發現窗口左側沒有出現這個項目,

***

右鍵項目 propeties---> project facets

去configure,配置完后才是下面這個圖:

3,現在可以add進tomcat了,以為我src下面有幾個source folder,還要配置一下deployment,這幾個文件的映射好像是我手動加的

4,啟動tomcat后,發現

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

去webapps下面看,發現web-inf下面沒有lib,

對比了其他gradle項目,發現在.classpath文件中少了下面標黃部分:

<classpath>
    <classpathentry kind="src" path="src/main/java">
        <attributes>
            <attribute name="FROM_GRADLE_MODEL" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" path="src/main/resources">
        <attributes>
            <attribute name="FROM_GRADLE_MODEL" value="true"/>
        </attributes>
    </classpathentry>
    
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7/"/>
    <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">
        <attributes>
            <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

然后啟動就正常了。

 

我中間參考其他gradle項目還手動改了 .project文件:也是少了黃色部分,然而我把那個項目的.project全部拷貝過來了:忘記是遇到什么問題了

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>CPFServer</name>
    <comment>Project CPFServer created by Buildship.</comment>
    <projects>
    </projects>
    <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.buildship.core.gradleprojectbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.wst.validation.validationbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
        <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
        <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<!--         <nature>org.eclipse.wst.jsdt.core.jsNature</nature> -->
    </natures>
</projectDescription>

 

 

 

*


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM