*
背景:在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>
*
时间: 2024-10-19 20:44:33