gpt4 book ai didi

eclipse - spring boot 使用 springloaded 在 gradle 中没有工作

转载 作者:行者123 更新时间:2023-12-03 05:13:42 25 4
gpt4 key购买 nike

当我在我的项目中使用 springloaded 时。 Spring Boot + Spring-Loaded (IntelliJ, Gradle) 中有类似的问题
根据document ,
我的 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 中运行应用程序时。 Spring 加载不工作。
然后我关注 springloaded document , 添加 -javaagent:<pathTo>/springloaded-{VERSION}.jar -noverify运行配置
最后它运行良好。
enter image description here

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

最佳答案

我看到你使用 spring 1.3.x

Spring 加载在阁楼上:https://spring.io/projects

从现在开始你应该使用 DevTools:https://spring.io/blog/2015/06/17/devtools-in-spring-boot-1-3

有几个选项可用(DevTools、Spring 加载、JRebel 等)

DevTools 是推荐的 Spring 方式,而不是唯一的方式。

来自文档:“有几个热重载选项。推荐的方法是使用 spring-boot-devtools,因为它提供了额外的开发时功能,例如支持快速应用程序重启和 LiveReload 以及合理的开发时配置(例如模板缓存)。

或者,在 IDE 中运行(尤其是在调试时)是进行开发的好方法(所有现代 IDE 都允许重新加载静态资源,通常还允许热交换 Java 类更改)。

spring-boot-devtools 模块包括对自动应用程序重启的支持。虽然不像 JRebel 或 Spring Loaded 这样的技术那么快,但它通常比“冷启动”快得多。在研究下面讨论的一些更复杂的重新加载选项之前,您可能应该尝试一下。”

Spring 加载目前不是很活跃:https://github.com/spring-projects/spring-loaded/releases因此为什么它在 Spring 项目页面的阁楼上。

关于eclipse - spring boot 使用 springloaded 在 gradle 中没有工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38096112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com