0

我正在使用 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:|here is my path to springloaded.jar| -noverify。我在部署选项卡上选择了爆炸的工件。

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

  • 简单的热交换不适用于 springloaded 代理,但没有它也可以
  • 看起来 Tomcat 使用\out\artifacts\expecker\exploded\expecker-1.0 - SNAPSHOT.war \ 文件夹,但是当我做项目时,更改只反映在\build \ 文件夹中。


有人可以帮我吗?

4

1 回答 1

0

我的错,弹簧加载不支持添加新类。所以,实际上,一切都按预期工作。

于 2016-02-06T23:13:34.883 回答