如何在IntelliJ中的spring启动项目中使用实时编辑 [英] How to use live edit in a spring boot project in IntelliJ

查看:738
本文介绍了如何在IntelliJ中的spring启动项目中使用实时编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是网络开发的新手。我发现IntelliJ中的实时编辑功能非常有用。我的问题是,我正在为一个春季启动项目的百万富翁页面工作,我无法让实时编辑工作。



如果我创建一个静态Web项目并创建一个html文件,我可以右键单击该文件并单击调试模式,实时编辑将开始,chrome将开始使用的IntelliJ。但在spring项目中,右键单击不会给我调试html文件的选项。如果我用chrome打开文件,右键单击页面并选择在IDEA中检查,它将与IntelliJ连接,但每次我对文件进行更改时,我都必须刷新浏览器才能获得更改。



我没有安装任何插件。我今天下载了IntelliJ终极版,它带有实时编辑,我刚启用它。



有没有办法在spring项目中调试html文件?或者有什么工作吗?

解决方案

这就是 spring-boot-devtools with LiveReload 来解决




使用spring-boot-devtools的应用程序每当类路径上的文件变为
时自动重启



现在,每当您对 html 文件进行任何更改时,都会自动检测并反映更​​改在您的浏览器上。


I am new to web development. I found the live edit feature in IntelliJ really useful. My problem is, I am working on a thymeleaf page for a spring boot project and I can't get live edit to work.

If I create a static web project and create an html file, I can right click on the file and click debug mode, live edit will begin and chrome will start working with IntelliJ. But in a spring project, right clicking won't give me the option to debug the html file. If I open the file in chrome, right click on the page and choose "inspect in IDEA", it will connect with IntelliJ, but every time I make changes to the file, I will have to refresh the browser get the changes.

I did not install any plugins. I downloaded IntelliJ ultimate today and it comes with live edit, I just enabled it.

Is there a way to debug just the html file in a spring project? Or is there any work around?

解决方案

That's what spring-boot-devtools with LiveReload come to resolve

Applications that use spring-boot-devtools automatically restart whenever files on the classpath chang more info here

Start by adding this to your pom file:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

or Gradle

dependencies {
    compile("org.springframework.boot:spring-boot-devtools")
}

Spring uses Restart technology to make reloading faster. But changes to your resources folder, by default, does not trigger a restart. This is when the folks at Spring thought of including

an embedded LiveReload server that can be used to trigger a browser refresh when a resource is changed.

To make fully use of this feature, you need to download an extension from livereload.com that you install in your browser or just google for it (e.g. livereload chrome).

Enable the extension by clicking: Enable LiveReload

Now whenever you make any change to your html files, changes automatically are detected and reflected on your browser.

这篇关于如何在IntelliJ中的spring启动项目中使用实时编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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