Spring Boot devtools IntelliJ [英] Spring Boot devtools IntelliJ

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

问题描述

我使用Spring Boot 1.3.0.M5,我试图利用devtools。这使您可以在开发过程中对应用程序进行更改,并可以重新加载应用程序。我已经在使用Java和Maven的STS中看到了这个演示工作。

我正在尝试使用Groovy&在IntelliJ 14.1中使用Gradle,我遇到了一些问题。首先这里是我的Gradle Build依赖关系。

 依赖项{
compile(org.springframework.boot:spring-boot-devtools)
编译(org.springframework.boot:spring-boot-starter-web)
编译(org.codehaus.groovy:groovy)
testCompile(org.springframework.boot:spring-boot -starter-test)
}

我创建了一个控制器,

 包演示

导入org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class HomeController {

@RequestMapping(/)
public String home(){
Hello,SpringOne 2GX!
}

}

我可以运行应用程序并访问 http:// localhost:8080 并查看字符串print到屏幕。如果我对文件进行更改,则不会发生任何事情,因为IntelliJ不会在更改时编译。如果你去Build> Make Project,虽然我可以在控制台重新加载中看到Spring Boot。所以这似乎是工作,但如果我回到根URL我得到以下错误,这基本上是你会看到,如果你没有控制器的地方。


白标签错误页面



此应用程序没有显式映射/ error,所以你看到
这是一个后备。



Thu Sep 17 10:43:25 EDT 2015有一个意外的错误(type = Not
发现,状态= 404)。没有消息可用


任何人都知道为什么重新加载对我无法正常工作?

解决方案

我最近有同样的问题。问题在于devtools拦截变化的方式。默认情况下,等待编译完成1秒钟。如果classpath在那段时间之后不存在,那么devtools会认为class已被删除,并在没有它的情况下重新启动应用程序。

Groovy在我的机器上完成编译过程的平均时间大约需要3秒。因此,类重新启动时被删除。



此问题的解决方案是在应用程序中设置 spring.devtools.restart.pollInterval 属性.properties 文件的值大于1000(对于我,4000可以正常工作)。


I am using Spring Boot 1.3.0.M5 and I am trying to take advantage of devtools. This allows you to make changes to your application while in development and boot will reload your application. I have seen this demo work in STS using Java and Maven.

I am trying to use Groovy & Gradle in IntelliJ 14.1 and I am having some issues. First here is my Gradle Build dependencies.

dependencies {
    compile("org.springframework.boot:spring-boot-devtools")
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.codehaus.groovy:groovy")
    testCompile("org.springframework.boot:spring-boot-starter-test") 
}

I created a controller with a mapping for "/"

package demo

import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class HomeController {

    @RequestMapping("/")
    public String home(){
        "Hello, SpringOne 2GX!"
    }

}

I am able to run the application and visit http://localhost:8080 and see the string print to the screen. If I make a change to the file nothing happens because IntelliJ does not compile on change. If you go to Build > Make Project though I can see Spring Boot in the console reload. So this seems to be working but if I go back to the root URL I get the following error which is basically what you would see if you had no controllers in place.

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Sep 17 10:43:25 EDT 2015 There was an unexpected error (type=Not Found, status=404). No message available

Anyone know why the reload is not working correctly for me?

解决方案

I had the same issue recently. The problem is in the way devtools intercepts changes. By default it waits for 1 second for compiling to be finished. If class doesn't exist on classpath after that time then devtools consider class was deleted and restart application without it.

Most times it takes 3 second in average for groovy to finish compilation process on my machine. Therefore class getting removed while restart.

The solution for this issue is to set spring.devtools.restart.pollInterval property in application.properties file to value greater than 1000 (for me 4000 works fine).

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

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