IntelliJ + Tomcat + Spring-Loaded [英] IntelliJ + Tomcat + Spring-Loaded

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

问题描述

我想试试Spring Source的Spring Loaded类重载代理,Tomcat通过IntelliJ运行。

I would like to try out Spring Source's "Spring Loaded" class reloading agent, with Tomcat run via IntelliJ.

https://github.com/SpringSource / spring-loaded

我已经将JVM参数添加到我的Tomcat运行配置中,我的webapp启动时没有错误,似乎表现正常。

I've added the JVM arguments to my Tomcat run configuration, and my webapp starts up without errors and seems to behave normally.

我不确定如何触发类重新加载。我只需要编译我修改的类吗?我试过了,但似乎没有用。我是否需要更新Tomcat并部署类和资源?这似乎不起作用......?

I'm not really sure how to trigger the class reloading though. Do I just need to compile the classes that I modify? I've tried that and that didn't seem to work. Do I need to update Tomcat and deploy classes and resources? That doesn't seem to work either...?

任何具体的配置细节将不胜感激。

Any specific configuration details would be greatly appreciated.

编辑:更多信息,我认为我的问题可能与使用两个模块有关,一个是核心代码库,另一个是webapp。我将Maven用于两者,一个配置为jar项目,另一个配置为war项目。 IntelliJ为爆炸战争设置Artifact以使用jar模块的jar文件。我已经尝试切换Artifact配置,将jar模块的编译输出合并到WEB-INF / classes中。现在我在target / webapp / WEB-INF / class / etc中看到.class文件。但我不知道如何在编辑时让IntelliJ更新特定的类文件。

More info, I think my problem may have to do with using two modules, one a core code library, and one the webapp. I use Maven for both, one configured as a jar project and the other as a war project. IntelliJ sets up the Artifact for the exploded war to use the jar module's jar file. I've tried switching the Artifact config to incorporate the jar module's compiled output into WEB-INF/classes instead. Now I see the .class files in target/webapp/WEB-INF/class/etc. But I'm not sure how to get IntelliJ to update a specific class file when I edit it.

推荐答案

如果你添加了以下jvm参数(如Springloaded页面所述)到你的tomcat

If you added the following jvm parameters (as described at the springloaded page) to your tomcat

-javaagent:<pathTo>/springloaded-{VERSION}.jar -noverify SomeJavaClass

你应该没事。对于您正在测试的webapp,在tomcat中禁用自动重新加载可能会有所帮助。对于server.xml中的例子:

you should be fine. It may help to disable auto reloading in tomcat for the webapp you are testing. For exmaple in your server.xml:

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
    <Context docBase="projekt" path="/projekt" reloadable="false" ...

这确保只有springloaded类加载器加载更改的类。

This ensures that only the springloaded classloader loads changed classes.

这篇关于IntelliJ + Tomcat + Spring-Loaded的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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