简体   繁体   English

为什么Java动态服务器只能在独立的Tomcat上运行但不能在Eclipse上运行

[英]Why java dynamic server just works on stand alone Tomcat but not eclipse

First of all, i don't know if i wrote the question correctly or not. 首先,我不知道我是否正确地写了这个问题。

I have a dynamic web server that I developed on eclipse, and when I run it on eclipse, using Tomcat 8.0.33 i get this 我有一个在eclipse上开发的动态Web服务器,当我在Eclipse上使用Tomcat 8.0.33运行它时,我得到了这个

在此处输入图片说明

however, if i compiled and build the project and extracted the war file, then put that war file into the work web apps folder into Tomcat installation directory, and then run Tomcat from terminal using startup.sh , it works perfectly, see please 但是,如果我编译并生成了项目并提取了war文件,则将该war文件放入工作web apps文件夹中的Tomcat安装目录中,然后使用startup.sh从终端运行Tomcat,它可以正常运行,请参阅

在此处输入图片说明

i tried another version of Tomcat, 8.0.24, and the same problem happened. 我尝试了另一个版本的Tomcat 8.0.24,并且发生了相同的问题。

i am using eclipse Luna Service Release 2 (4.4.2) on mac os El Captine 我在mac os El Captine上使用Eclipse Luna Service Release 2 (4.4.2)

Update 1 更新1

Maybe because I deleted the web content folder and i am putting my files in src/main/webapp 可能是因为我删除了web content文件夹,并将文件放在src/main/webapp

and that is what I do in pom 这就是我在pom中所做的

<plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <failOnMissingWebXml>true</failOnMissingWebXml>
                    <webResources>
                        <resource>
                            <directory>src/main/webapp</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

Do you think so? 你这样认为吗? if yes how to solve it please ? 如果是的话,如何解决?

If the project is webtools dynamic project, you can edit the file $PROJECT_HOME/.settings/org.eclipse.wst.common.component . 如果该项目是webtools动态项目,则可以编辑$ PROJECT_HOME / .settings / org.eclipse.wst.common.component文件 Modify the attribute value of source-path of wb-resource element. 修改wb-resource元素的source-path属性值。

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="SemanticRecommenderWebservices">
        <wb-resource deploy-path="/" source-path="/src/main/webapp"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/java"/>
        <property name="context-root" value="SemanticRecommenderWebservices"/>
        <property name="java-output-path" value="src/main/webapp/WEB-INF/classes"/>
    </wb-module>
</project-modules>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM