在IntelliJ IDEA中设置Tomcat的问题 [英] Problems setting up tomcat in intellij idea

查看:537
本文介绍了在IntelliJ IDEA中设置Tomcat的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用intellij想法创建一个简单的可测试的宁静Web服务.我正在学习本教程: https: //medium.com/@jamsesso/starting-out-with-jersey-apache-tomcat-using-intellij-6338d93ffd40

I'm trying to create a simple test restful web service using intellij idea. I'm following this tutorial: https://medium.com/@jamsesso/starting-out-with-jersey-apache-tomcat-using-intellij-6338d93ffd40

但是,我在运行它时遇到了一些问题.每次运行它后,我每次进入localhost:8080/,它都会向我显示error 404和消息

But, i got some problems running it. Every time i go to localhost:8080/ after running it, it shows me error 404 and the message

The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

.并且,在intellij中,存在大量错误.我将第一个放在这里:

. And, in intellij, there is a extense list of errors. I'll put the first one here:

13-Jan-2019 15:34:28.861 GRAVE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]

在开始时,它显示以下内容:

At the beggining, it shows this:

F:\Java\apache-tomcat-9.0.13\bin\catalina.bat run
[2019-01-13 03:34:27,290] Artifact RestTeste:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE:   "C:\Users\vitor\.IntelliJIdea2018.2\system\tomcat\Tomcat_9_0_13_RestTeste"
Using CATALINA_HOME:   "F:\Java\apache-tomcat-9.0.13"
Using CATALINA_TMPDIR: "F:\Java\apache-tomcat-9.0.13\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_111"
Using CLASSPATH:       "F:\Java\apache-tomcat-9.0.13\bin\bootstrap.jar;F:\Java\apache-tomcat-9.0.13\bin\tomcat-juli.jar"

我认为tomcat可能没有正确的配置,但是我找不到错误的配置.我在intellij和tomcat之间寻找环境变量和java版本,但是我可以确切地说出是否是问题之一. Java_homecatalina_home分别设置为jdk文件夹和tomcat文件夹,从我所看到的来看,版本是正确的.我对这个问题完全迷失了,在超过4个小时内找不到任何解决方案.

I think tomcat is maybe not with the right configs, but i couldn't find the ones that are wrong. I looked for environment variables and java version between intellij and tomcat, but i could say precisely if one of this was the problem. Java_home and catalina_home was set up to jdk folder and tomcat folder, respectively, and from what i saw, the versions were correct. I'm completely lost regarding this problem, and couldn't find any solution in more than 4 hours.

可能是什么问题?

我是否错过了tomcat或intellij中的某些配置步骤?我正在读取tomcat文件夹中的running.txt文件,并按照配置该文件的步骤进行操作,但是没有成功.

Am i missing some configuration step in tomcat or in intellij? I was reading the running.txt file inside of tomcat folder and followed the steps to configure it but no success.

非常感谢!

更新:我尝试做其他事情,因此在这里值得一提.我尝试通过apache tomcat网站下载的.exe进行安装.它工作正常,我启动了它,并在localhost:8080处显示了默认的tomcat页面.然后,我去了intellij,并将这个新版本的tomcat添加到了我的应用程序服务器中,该服务器位于C:\ Program Files \ Apache Software Foundation \ Tomcat 9.0中.当我尝试运行它时,一开始,它给了我一个错误,那就是本地主机已在使用中,但是我关闭了tomcat并再次尝试并成功了.至少是部分.它给我的错误与以前相同,并且仅运行localhost:8080会给我以下消息:源服务器未找到目标资源的当前表示,或不愿意透露该资源的存在."再次.我尝试将我的jre_home变量更改为C:\ Program Files \ Java \ jre1.8.0_191,如yan所建议的那样,但它仍显示使用JRE_HOME:"C:\ Program Files \ Java \ jdk1.8.0_111".如果我在cmd中回显%JRE_HOME%,它将打印jre路径,而不是jdk路径.你们能帮我吗? 要添加应用服务器,我只是选择了tomcat及其路径. 再次输入初始文本:

UPDATE: I tried to do other stuff so it's worth pointing out here. I tried the install through the .exe downloaded in apache tomcat website. It worked fine, i started it and at localhost:8080 it shows me the default tomcat page. I then went to intellij and added this new version of tomcat to my application servers, located in C:\Program Files\Apache Software Foundation\Tomcat 9.0. When i tried to run it, at first, it gave me the error that localhost was already in use, but i closed tomcat and tried again and it worked. At least, partially. It gives me the same errors than before and running only localhost:8080 gives me the message "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists." again. I tried changing my jre_home variable to C:\Program Files\Java\jre1.8.0_191, as the answer from yan suggested, but it continued to show Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_111". If i echo %JRE_HOME% in cmd it will print the jre path, not the jdk one. Can you guys help me? To add the application server, i simply selected tomcat and the path to it. The initial text, again:

Using CATALINA_BASE:   "C:\Users\vitor\.IntelliJIdea2018.2\system\tomcat\Tomcat_9_0_8_RestTest"
Using CATALINA_HOME:   "C:\Program Files\Apache Software Foundation\Tomcat 9.0"
Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_111"
Using CLASSPATH:       "C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\tomcat-juli.jar"

我的环境变量的图像:

An image of my envinroment variables:

更新2 :这是根据要求打印的我正在运行的配置:

Update 2: here's a print of my running configurations, as requested:

推荐答案

确保已在部署"选项卡中添加了工件(请参见下面的屏幕截图)!

Make sure that you added your artifact(s) in the Deployment tab (see screenshot below)!

完成此操作后,您就可以运行项目了,应该没问题.

After do this, you run your project and it should be ok.

这篇关于在IntelliJ IDEA中设置Tomcat的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆