IntelliJ IDEA中Java类资源的自动重载
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24682366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Automatic reloading of Java class resources in IntelliJ IDEA
提问by Ruraj
In Eclipse, when developing web apps, for example, any changes to HTML files inside packages are automatically reflected when viewed in browsers even when the program is running.
例如,在 Eclipse 中,在开发 Web 应用程序时,即使程序正在运行,在浏览器中查看包内 HTML 文件的任何更改都会自动反映出来。
This does not seem to be the case in IntelliJ IDEA. So I need to re-run the program every time I make small changes to HTML. Is there a setting that will enable this, or is it not possible at all?
在 IntelliJ IDEA 中似乎并非如此。所以我每次对 HTML 进行小的更改时都需要重新运行程序。是否有设置可以启用此功能,或者根本不可能?
回答by amichaud
Eclipse automatically makes your project by default, while IntelliJ doesn't. That explains the difference of behaviour.
默认情况下,Eclipse 会自动创建您的项目,而 IntelliJ 不会。这解释了行为的差异。
You can "make" (Ctrl+F9) manually as yo need to reload resources. You shouldn't have to restart your app, and it should be really faster.
您可以手动“制作”(Ctrl+F9),因为您需要重新加载资源。你不应该重新启动你的应用程序,它应该更快。
Or you can enable it in your compiler settings but could produce some freezing of your environment so that is may be not what you want.
或者您可以在编译器设置中启用它,但可能会导致您的环境冻结,因此这可能不是您想要的。
回答by Harsha
I'm using Netbeans and using Google Chrome with netbeans connector, when making any changes to our code it's automatically updated on browser. I dont know any feature for IntelliJ IDEA. but I suggest you to try on netbeans.
我正在使用 Netbeans 并使用带有 netbeans 连接器的 Google Chrome,当对我们的代码进行任何更改时,它会在浏览器上自动更新。我不知道 IntelliJ IDEA 的任何功能。但我建议你试试netbeans。
You can download Netbeans Connector for Google Chrome from this link. download netbeans connector
您可以从此链接下载适用于 Google Chrome 的 Netbeans 连接器。 下载 netbeans 连接器
回答by geoand
When an application is being debugged in IntellJ IDEA, you can reload all the changed classes and resources from the menu:
在 IntellJ IDEA 中调试应用程序时,您可以从菜单中重新加载所有更改的类和资源:
Run
-> Reload Changed Classes
Run
-> Reload Changed Classes
If you are debugging a war with Refresh resources on frame
enabled, then the reload process is done automatically.
如果您正在调试Refresh resources on frame
启用的War,则重新加载过程会自动完成。
回答by Louise
1) Make sure on server start the artifact that is deployed is the "exploded" on, not a packaged version. (See for example this SO question: "Update resources" option missing in IntelliJ IDEA)
1)确保在服务器启动时部署的工件是“爆炸”的,而不是打包的版本。(例如,请参阅此 SO 问题:IntelliJ IDEA 中缺少“更新资源”选项)
2) When hitting the run or debug buttons there's a dialog for what can be done. The options "Update resources" and "Update resources and classes" both swap the changed HMTL/CSS files without redeployment.
2)点击运行或调试按钮时,会出现一个对话框,说明可以做什么。选项“更新资源”和“更新资源和类”都无需重新部署即可交换更改的 HMTL/CSS 文件。
Alternatively, you can use Ctrl+F10 to update. On first use it will show the same dialog, but you can select your preferred option and tick the "don't ask again" box. After that it's just quickly hitting CTRL+F10 before switching to the browser.
或者,您可以使用 Ctrl+F10 进行更新。首次使用时,它会显示相同的对话框,但您可以选择首选选项并勾选“不再询问”框。之后,它只是在切换到浏览器之前快速按下 CTRL+F10。
OR
或者
There is also the option to update changed resources on frame deactivation, which seems to be the Eclipse feature you asked for. A description on how to set this up can be found here: https://www.jetbrains.com/idea/help/updating-applications-running-on-application-servers.htmlor another step-by-step-guide here: IntelliJ and Tomcat....changed files are not automatically recognized by Tomcat
还有一个选项可以在框架停用时更新更改的资源,这似乎是您要求的 Eclipse 功能。可以在此处找到有关如何设置的说明:https: //www.jetbrains.com/idea/help/updating-applications-running-on-application-servers.html或此处的其他分步指南: IntelliJ 和 Tomcat....更改的文件不会被 Tomcat 自动识别
回答by kravemir
With Gradle you can run continuous build in background. Run in root folder of the project:
使用 Gradle,您可以在后台运行连续构建。在项目的根文件夹中运行:
./gradlew --continuous classes
Or, for only assets:
或者,仅针对资产:
./gradlew --continuous processResources
It works with LiveReloadof spring-boot-devtools.
它适用于spring-boot-devtools 的LiveReload。