gpt4 book ai didi

spring - Intellij + Gradle + SpringLoaded + Tomcat

转载 作者:行者123 更新时间:2023-11-28 23:27:20 24 4
gpt4 key购买 nike

我正在使用 Gradle、Intellij 和 Tomcat 开发 Spring 休息服务。我想在不重新部署的情况下重新加载我的更改,所以我使用 SpringLoaded。但它不会重新加载我的项目。即使热插拔也不起作用。这是我的 build.gradle:

def group = 'com.expecker'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'maven'
sourceCompatibility = 1.8
targetCompatibility = 1.8
def springVersion = '4.0.0.RELEASE'
def hibernateVersion = '5.0.7.Final'
def junitVersion = '4.11'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: junitVersion
compile "org.springframework:spring-core:$springVersion"
compile "org.springframework:spring-web:$springVersion"
compile "org.springframework:spring-webmvc:$springVersion"
compile "org.springframework:spring-orm:$springVersion"
compile "org.springframework:spring-jdbc:$springVersion"
compile "org.springframework:spring-tx:$springVersion"
compile "org.springframework:spring-orm:$springVersion"
compile "org.springframework:spring-context:$springVersion"
compile 'javax.servlet:javax.servlet-api:3.1.0'
compile 'jstl:jstl:1.2'
compile 'javax.servlet.jsp:jsp-api:2.2'
// compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13' it seems like this library isn't compatible with spring 4.1.x
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.4'
compile "org.hibernate:hibernate-core:$hibernateVersion"
compile "org.hibernate:hibernate-entitymanager:$hibernateVersion"
compile 'commons-dbcp:commons-dbcp:1.4'
//compile('org.springframework:springloaded:1.2.5.RELEASE')
}
buildscript {
repositories { jcenter() }
dependencies {
classpath 'org.springframework:springloaded:1.2.5.RELEASE'
}
}
apply plugin: 'idea'
idea {
module {
inheritOutputDirs = false
outputDir = file("$buildDir/classes/main/")
}
}
/*
When built in OpenShift the 'openshift' profile will be used when
invoking mvn.
Use this profile for any OpenShift specific customization your app
will need.
By default that is to put the resulting archive into the 'webapps'
folder.
http://maven.apache.org/guides/mini/guide-building-for-different-environments.html
*/
gradle.buildFinished { buildResult ->
println 'Building pom.xml...'
pom {
project {
groupId "${group}"
artifactId 'app'
version "${version}"
packaging 'war'
}.withXml {
asNode().appendNode('profiles').
appendNode('profile').with {
appendNode('id', 'openshift')
appendNode('build').with {
appendNode('finalName', 'expecker')
appendNode('plugins').appendNode('plugin').with {
appendNode('artifactId', 'maven-war-plugin')
appendNode('version', '2.1.1')
appendNode('configuration').with {
appendNode('outputDirectory', 'deployments')
appendNode('warName', 'expecker')
}
}
}
}
}
}.writeTo("pom.xml")}

在我的 Tomcat 配置中,我有 vm 选项 -javaagent:|这是我到 springloaded.jar 的路径| -noverify。我在部署选项卡上选择了分解工件。

如您所见,我尝试将我的 springloaded jar 包含到类路径中(我不知道为什么需要它,我在一些文章中看到了)。我试图将此 jar 添加为编译依赖项,但我无法构建项目。 我也试图不包括它,只在 vm 选项中设置。以下是我的一些观察:

  • 简单的热插拔不适用于 springloaded 代理,但没有它也可以工作
  • 看起来 Tomcat 使用 \out\artifacts\expecker\exploded\expecker-1.0-SNAPSHOT.war\文件夹,但是当我做项目时,变化是仅反射(reflect)在 \build\文件夹中。


谁能帮帮我?

最佳答案

我的错,spring loaded 不支持添加新类。所以,实际上,一切都按预期进行。

关于spring - Intellij + Gradle + SpringLoaded + Tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35246685/

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