0

当我在我的项目中使用 springloaded 时。Spring Boot + Spring-Loaded (IntelliJ, Gradle)中有一个类似的问题, 根据文档,我的 build.gradle 是:

buildscript{
ext{
    springBootVersion = '1.3.5.RELEASE'
}
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath 'org.springframework:springloaded:1.2.0.RELEASE'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
//apply plugin: 'application'
springBoot {
    backupSource = false
    mainClass = 'com.zhb.app.PortalApplication'
}

jar {
    baseName = 'springBootTest'
    version =  '0.0.1-SNAPSHOT'
}

//applicationDefaultJvmArgs = ['-javaagent:E:\\xgsdk\\commonLib\\springloaded-1.2.5.RELEASE.jar -noverify']

repositories {
    mavenCentral()
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-web",
            "com.alibaba:fastjson:1.2.4",
            "commons-codec:commons-codec:1.5",
            "org.apache.commons:commons-lang3:3.3.2"

    testCompile("org.springframework.boot:spring-boot-starter-test")
}

当我在 Eclipse 中运行应用程序时。弹簧加载不工作。
然后我按照弹簧加载的文档,添加-javaagent:<pathTo>/springloaded-{VERSION}.jar -noverify运行配置 最后它运行良好。 在此处输入图像描述

有两个问题出现在我的脑海中。
首先是弹簧加载的依赖classpath'org.springframework:springloaded:1.2.0.RELEASE'是没有必要的。
第二个是有办法-javaagent:<pathTo>/springloaded-{VERSION}.jar -noverifybuild.gradle中定义 VM 参数。
我看到了gradle 文件。在我的 build.gradle 中,注释代码正在显示
//apply plugin: 'application' //applicationDefaultJvmArgs = ['-javaagent:E:\\xgsdk\\commonLib\\springloaded-1.2.5.RELEASE.jar -noverify']
,但它不起作用。

4

1 回答 1

1

I see that you use spring 1.3.x

Spring loaded is in the attic: https://spring.io/projects

You should use DevTools from now on: https://spring.io/blog/2015/06/17/devtools-in-spring-boot-1-3

Several options are available (DevTools, Spring loaded, JRebel, etc.)

DevTools is the recommended Spring way, not the only way.

From the docs: "There are several options for hot reloading. The recommended approach is to use spring-boot-devtools as it provides additional development-time features such as support for fast application restarts and LiveReload as well as sensible development-time configuration (e.g. template caching).

Alternatively, running in an IDE (especially with debugging on) is a good way to do development (all modern IDEs allow reloading of static resources and usually also hot-swapping of Java class changes).

The spring-boot-devtools module includes support for automatic application restarts. Whilst not as fast a technologies such as JRebel or Spring Loaded it’s usually significantly faster than a “cold start”. You should probably give it a try before investigating some of the more complex reload options discussed below."

Spring loaded is not very active at the moment: https://github.com/spring-projects/spring-loaded/releases hence why it's in the attic on the spring project page.

于 2016-06-29T13:10:08.510 回答