[英]Tomcat server within eclipse not working for Gradle build project
I have a test project build using Gradle. 我有一个使用Gradle的测试项目构建。 I am trying to create a web application that will say Hello gradle (I am new to gradle or any build tool for that matter, so I wanted to test before getting into my project).
我正在尝试创建一个Web应用程序,它会说Hello gradle(我是gradle或者任何构建工具的新手,所以我想在进入我的项目之前进行测试)。 Here is my directory structure:
这是我的目录结构:
|
| build\
| build.gradle
| gradle\
| gradlew
| gradlew.bat
| README.md
| WebContent
| index.html
This is generated after running gradle wrapper
, gradle eclipseWtp
and gradle build
. 这是在运行
gradle wrapper
, gradle eclipseWtp
和gradle build
之后生成的。 ( In no particular order). (没有特别的顺序)。 The build script I used is:
我使用的构建脚本是:
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
repositories {
mavenCentral()
}
// See http://gradle.org/docs/current/userguide/war_plugin.html
// Section 26.5. Convention properties
project.webAppDirName = 'WebContent'
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
}
task wrapper (type: Wrapper){
gradleVersion = '2.11'
}
I am able to successfully import this project to eclipse. 我能够成功将此项目导入eclipse。 I use eclipse for all the development and hence want the option of running the project from the tomcat within eclipse.
我使用eclipse进行所有开发,因此需要在eclipse中从tomcat运行项目的选项。 It works fine for a Dynamic Web Project created using eclipse, but isn't working for my gradle build project.
它适用于使用eclipse创建的动态Web项目,但不适用于我的gradle构建项目。
The server is not starting with the following error 服务器未启动以下错误
Setting property 'source' to 'org.eclipse.jst.j2ee.server:GradleTest' did not find a matching property.
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /path/to/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/GradleTest does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:136)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:5132)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5319)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/GradleTest]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1122)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/GradleTest]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
... 6 more
Caused by: org.apache.catalina.LifecycleException: Error in resourceStart()
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5320)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
I did some reading and found that adding eclipse-wtp
solved the problem for this guy. 我做了一些阅读,发现添加
eclipse-wtp
解决了这个家伙的问题。 But that doesn't solve my problem. 但这并不能解决我的问题。 What addition configurations do I need to get tomcat running from eclipse?
从Eclipse中运行tomcat需要哪些附加配置?
Also the gradle built project doesn't have Deployment Descriptor, JAX-WS Web Services, Javascript Resources
that normally appears in a Dynamic Web Project in eclipse. 此外,gradle构建的项目没有
Deployment Descriptor, JAX-WS Web Services, Javascript Resources
,这些Deployment Descriptor, JAX-WS Web Services, Javascript Resources
通常出现在eclipse中的Dynamic Web Project中。
将Source配置为/WebContent
并在部署中部署Path /
在项目属性中的程序集为我启动了tomcat服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.