Java webapp在spring引导更新到1.3.1后不会启动

Java webapp在spring引导更新到1.3.1后不会启动,java,spring,gradle,spring-boot,h2,Java,Spring,Gradle,Spring Boot,H2,我希望你能帮我解决这个问题,但却找不到解决办法。 我正在使用Gradle2.4、Java8、Spring boot和H2-DB开发一个Web应用程序。不久前,我们开始使用SpringBoot 1.2.2,并决定将SpringBoot更新为1.3.1。但是这个版本的服务器不再启动了。当我启动项目时,它抛出一个NullPointerException(GradleBootRun) build.gradle: buildscript { // The buildscript closure is e

我希望你能帮我解决这个问题,但却找不到解决办法。 我正在使用Gradle2.4、Java8、Spring boot和H2-DB开发一个Web应用程序。不久前,我们开始使用SpringBoot 1.2.2,并决定将SpringBoot更新为1.3.1。但是这个版本的服务器不再启动了。当我启动项目时,它抛出一个NullPointerException(GradleBootRun)

build.gradle:

buildscript {

// The buildscript closure is executed at the beginning of gradle's configuration phase.
// It defines dependencies on gradle plugins that are used in the remaining configuration phase
// and in the execution phase.
// Note that spring-boot registers a custom Gradle ResolutionStrategy that allows to omit version numbers
// when declaring dependencies. Only the plugin version must be set.
ext {
    springBootVersion = '1.3.1.RELEASE'
}

// repositories used to resolve gradle plugins
repositories {
    maven { url "http://download.osgeo.org/webdav/geotools/"}
    mavenCentral()
    maven { url "http://repo.spring.io/libs-snapshot" }
    maven { url "http://dl.bintray.com/infinit/infinit-opensource" }
    maven { url "http://dl.bintray.com/letteral/opensource" }
    maven { url 'https://repo.gradle.org/gradle/plugins-releases'}
}


// dependent gradle plugins
dependencies {
    classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
    classpath "net.saliman:gradle-cobertura-plugin:2.3.0"
    classpath "com.letteral:letteral-gradle-plugin:0.0.5"
}

}

// repositories used for satisfying project's configuration dependencies (e.g. compile, runtime)
repositories {
maven { url "http://download.osgeo.org/webdav/geotools/"}
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" } // cobertura snapshots
maven { url "http://dl.bintray.com/infinit/infinit-opensource" }
maven { url "http://dl.bintray.com/letteral/opensource" }
maven { url 'https://repo.gradle.org/gradle/plugins-releases'}
}

// plugins needed in the build process
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'net.saliman.cobertura'
apply plugin: 'spring-boot'
apply plugin: 'letteral'
apply from: 'gensrc.gradle'
apply from: 'liquibase.gradle'

// check coverage limits locally with command '../gradlew cobertura coberturaCheck'
cobertura {
coberturaVersion = '2.1.1' // cobertura 2.1.x depends on asm-5 required for Java 8
coverageCheckHaltOnFailure = true // fail if coverage is below limits
coverageIgnoreTrivial = true // ignore simple getters and setters
coverageCheckBranchRate = 0 // minimum acceptable branch coverage rate (percent) needed by each class
coverageCheckLineRate = 0 // minimum acceptable line coverage rate (percent) needed by each class
coverageCheckTotalBranchRate = 50 // minimum acceptable branch coverage rate (percent) needed by the whole project
coverageCheckTotalLineRate = 50 // minimum acceptable line coverage rate (percent) needed by the whole project

coverageCheckRegexes = [
        // more fine grained limits per package
        [regex: 'com.infinit.atobcarry.config.*', branchRate: 0, lineRate: 0],
        [regex: 'com.infinit.atobcarry.entity.*', branchRate: 0, lineRate: 0]
]
//exclude the fixture files in order to get a realistic view of the coverage
coverageExcludes = [
        '.*\\.DevelopmentFixtures.*',
        '.*\\.Fixtures.*'
]
}
letteral {
username = 'username'
password = 'pass'
organization = 'org'
repos = files('mail')
apiUrl = 'http://letteral-dev.elasticbeanstalk.com/api'
}

configurations {
webapp  // configuration used to hold the build result of the client project
}

dependencies {
// spring boot dependencies
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-security"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-security"
compile "org.springframework.boot:spring-boot-starter-websocket"
compile "org.springframework:spring-context-support"
compile "org.springframework:spring-messaging"

//compile("org.springframework.boot:spring-boot-devtools")

// modelmapper
compile "org.modelmapper.extensions:modelmapper-spring:0.7.3"

// swagger
compile "com.mangofactory:swagger-springmvc:1.0.0"

// database dependencies
compile 'com.h2database:h2:1.4.190'
//    runtime 'org.postgresql:postgresql:9.4-1201-jdbc41'

// liquibase
runtime 'org.liquibase:liquibase-core:3.3.2'

// Joda
compile 'joda-time:joda-time:2.7'
compile 'org.jadira.usertype:usertype.spi:3.2.0.GA'
compile 'org.jadira.usertype:usertype.core:3.2.0.GA'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda';

// Apache commons
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'org.apache.commons:commons-io:1.3.2'

// java melody dependencies
compile 'net.bull.javamelody:javamelody-core:1.55.0'
runtime 'com.thoughtworks.xstream:xstream:1.4.8'
runtime 'org.jrobin:jrobin:1.5.9'

// Atmosphere SSE / Websockets
compile 'org.atmosphere:atmosphere-runtime:2.2.6'

// Jackson
compile 'com.fasterxml.jackson.core:jackson-core'
// letteral
compile 'com.letteral:letteral-client-java:0.0.17'

// tomtom
compile(group: 'com.tomtomworker.webfleet.connect', name: 'webfleet-connect-client', version: '1.1')

//google maps
compile 'com.google.maps:google-maps-services:0.1.7'

//quartz
compile(group: 'org.quartz-scheduler', name: 'quartz', version: '2.2.1')
compile(group: 'org.quartz-scheduler', name: 'quartz-jobs', version: '2.2.1')

//itext pdf generation
compile('com.itextpdf:itextpdf:5.5.6')
//xdocreport templating over freemarker
compile('fr.opensagres.xdocreport:xdocreport:1.0.3')
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.template:1.0.3')
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.template.freemarker:1.0.3')
//unfortuately we also need to include the velocity templates without using them
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.template.velocity:1.0.3')
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.converter.odt.odfdom:1.0.3')
//pdf signing with bouncy castle, must be 1.49 for now as itext 5.5.6 only supports BC 1.49
compile('org.bouncycastle:bcpkix-jdk15on:1.49')

//jts to create the tunnel
compile('com.vividsolutions:jts:1.13')
compile('org.geotools:gt-shapefile:14.0')
//compile('org.geotools:gt-swing:13.3')
compile('org.geotools:gt-epsg-hsql:14.0')

//javaxmail
compile 'javax.mail:mail:1.4.1'

//hazelcast
compile("com.hazelcast:hazelcast-all:3.5") {
    exclude group: 'org.freemarker'
}

// testing dependencies
testCompile("org.springframework.boot:spring-boot-starter-test") {
    // the following artifacts are excluded since spock is used:
    exclude group: 'org.mockito', module: 'mockito-core'
}

testCompile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
testCompile 'org.spockframework:spock-spring:1.0-groovy-2.4'
testCompile 'com.jayway.jsonpath:json-path:0.9.1'
testCompile 'cglib:cglib-nodep:3.1'

testCompile 'org.dbunit:dbunit:2.4.9'
testCompile 'com.github.springtestdbunit:spring-test-dbunit:1.2.1'

providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

// web resources from client project
webapp project(path: ':atobcarry-client', configuration: 'webapp')
}

// configure the war task to deploy on conventional servlet container (e.g. tomcat)
war {
// let war task depend on webapp configuration
// hereby start relevant tasks in the client project;
// when the war task runs execute the closure
// hereby unzip the client project's build result
// and add it to the resources path of the war
// This folder is exposed as static content by spring boot.
dependsOn(configurations.webapp)
from { zipTree(configurations.webapp.singleFile) }
baseName = 'atobcarry'
//version =  '0.1.0'
}

// docker packaging requires a jar file that is configured similarly to the war
jar {
dependsOn(configurations.webapp)
from(zipTree(configurations.webapp.singleFile)) {
    into 'META-INF/resources'
}
baseName = 'atobcarry'
//version =  '0.1.0'
}
import java.util.concurrent.CountDownLatch

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.0'
    }
}

apply plugin: 'org.asciidoctor.gradle.asciidoctor'

ext {
    applicationVersion = 'UNDEFINED'
    appBackend = null
}

asciidoctor {
    sourceDir = file('asciidoc')
    options = [
            doctype   : 'book',
            attributes: [
                    'source-highlighter': 'coderay',
                    toc                 : '',
                    idprefix            : '',
                    idseparator         : '-'
            ]
    ]
}

def defaultEnvironment() {
    def environment = ["PATH=${System.env.PATH}"]
    environment += "HOME=${System.env.HOME}"
    return environment
}

def execAsync(command, printStdOutput, dir, expectedOutput) {
    println("Starting async command $command")

    final CountDownLatch condition = new CountDownLatch(1)

    def commandEnvironment = defaultEnvironment()

    def proc = command.execute(commandEnvironment, new File(dir as String))
    Thread.start {
        try {
            proc.in.eachLine { line ->
                if (printStdOutput) {
                    println "$line"
                }
                if (expectedOutput != null && line?.contains(expectedOutput)) {
                    condition.countDown()
                }
            }
        }
        catch (ignored) {
        }
    }
    Thread.start {
        try {
            proc.err.eachLine { line ->
                if (printStdOutput) {
                    println line
                }
            }
        }
        catch (ignored) {
        }
    }
    return [proc, expectedOutput != null ? condition : null]
}


task startServer() {
    doLast {
        def condBackend
        (appBackend, condBackend) = execAsync(["./gradlew", "run"], true, "$projectDir", "Started Application")
        condBackend.await()
    }
}

task stopProcesses << {
    appBackend?.destroy()
}

task e2eReport(dependsOn: [startServer, ':atobcarry-client:clean', ':project-client:e2eTest'])
tasks.getByPath(':project-client:e2eTest').mustRunAfter(startServer)
stopProcesses.mustRunAfter(':project-client:e2eTest')
startServer.finalizedBy(stopProcesses)
e2eReport.finalizedBy(stopProcesses)
tasks.getByPath(':project-client:e2eTest').finalizedBy(stopProcesses)
task validate(dependsOn: [':project-client:grunt_default', ':project-server:cobertura', ':project-server:coberturaCheck'])
应用程序配置:

mail.host=localhost
mail.from=organization@organization.de
organization.serverURL=http://localhost:8080
organization.enableTomTomTracking=false
organization.disableQuartzJobsInDebugMode=false
organization.restUrlTrackingPositions=http://localhost:8080/api/v1/trackingPositions/
organization.gracePeriodExpiredRequestsMinutes=1
organization.gracePeriodExpiredOffersMinutes=1
organization.keystorePath=security/atobcarry
organization.truststorePath=security/cacerts
organization.keyPassword=password
organization.keyAlias=organization
organization.keystorePassword=changeit
organization.pdfHashingAlgorithm=SHA-256
liquibase.changeLog=classpath:/db/changelog/db.changelog-master.xml
liquibase.enabled=false
management.security.enabled:false
letteral.enabled=false
letteral.from=support@organization.com
letteral.apiKey=123456
letteral.apiUrl=http://letteral-dev.elasticbeanstalk.com/api
letteral.hoursTokenValid=24
letteral.organization=organization
letteral.repository=mail
letteral.release=not used
letteral.releaseVersion=not used
letteral.requestMailName=request
# google maps properties
googleMaps.directionsApiKey=xxxxx
googleMaps.mode=car
# for debugging letteral requests
# logging.level.org.apache.http.wire=DEBUG
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.password=
spring.datasource.url=jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;MODE=PostgreSQL
spring.datasource.username=dbuser
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.id.new_generator_mappings=true
#spring.jpa.show-sql=false
spring.jpa.open-in-view=true
spring.jpa.properties.jadira.usertype.autoRegisterUserTypes=true
spring.jpa.properties.jadira.usertype.databaseZone=UTC
spring.jpa.properties.jadira.usertype.javaZone=jvm
spring.jackson.dateFormat=yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
spring.messages.basename=com/infinit/atobcarry/messages



multipart.maxFileSize=10Mb
我希望这些都是相关信息。如果不够请告诉我

更新:以下是一些更相关的文件。重要的是:该项目包含两个“子项目”:服务器和客户端。客户端是纯Javascript,工作正常。上面的build.gradle是来自服务器的,我刚刚添加了主build.gradle和一些其他文件

应用程序类别:

@Configuration
@EnableJpaRepositories("com.infinit.atobcarry.repository")
@EnableAutoConfiguration
@EnableConfigurationProperties
@ComponentScan("com.infinit.atobcarry")
@EntityScan(basePackages = {"com.infinit.atobcarry.entity"})
@EnableJpaAuditing
@EnableAspectJAutoProxy
public class Application implements EmbeddedServletContainerCustomizer {

    public final static String API_PREFIX = "/api/v1";

    public final static String FRONTEND_PREFIX = "/#";

    // As a default it is assumed that the document root is the app folder of the client project.
    // Relative to the root of the project this is located in the following path:
    private final static String CLIENT_DOCUMENT_ROOT = "../atobcarry-client/app";

    /**
     * An embedded container is started, when the application is run via the main method.
     * It can be started with the gradle command bootRun
     *
     * @param args start parameters
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        SpringApplication app = new SpringApplication(Application.class);
        app.run(args);
    }

    /**
     * When running with an embedded servlet container additional configurations can be applied.
     *
     * @param container that is subject of the configuration
     */
    @Override
    public void customize(ConfigurableEmbeddedServletContainer container) {

        // The embedded servlet container shall use the resources from the client project
        configureDocumentRoot(container);

        // send charset in Content-Type response header to improve performance
        MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
        mappings.add("html", "text/html;charset=utf-8");
        container.setMimeMappings(mappings);
    }

    /**
     * Sets the document root to the resource folder of the client project if available.
     * This allows for instant reloading when developing the app.
     */
    private void configureDocumentRoot(ConfigurableEmbeddedServletContainer container) {
        String documentRootPath = CLIENT_DOCUMENT_ROOT;
        File documentRoot = new File(documentRootPath);
        if (documentRoot.isDirectory() && documentRoot.canRead()) {
            container.setDocumentRoot(documentRoot);
        }
    }
}

以下是更多信息:

这门课可能也很有趣:

/**
 * Servlet 3.0+ environments allow to replace the web.xml file with a programmatic configuration.
 * <p/>
 * Created by owahlen on 01.01.14.
 */
public class Deployment extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    /**
     * This method is copied from SpringBootServletInitializer.
     * Only the registration of the ErrorPageFilter is omitted.
     * This was done since errors shall never be sent as redirects but as ErrorDto
     * @param servletContext
     * @return
     */
    protected WebApplicationContext createRootApplicationContext(ServletContext servletContext) {
        SpringApplicationBuilder builder = new SpringApplicationBuilder();
        ApplicationContext parent = getExistingRootWebApplicationContext(servletContext);
        if (parent != null) {
            this.logger.info("Root context already created (using as parent).");
            servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, null);
            builder.initializers(new ParentContextApplicationContextInitializer(parent));
        }
        builder.initializers(new ServletContextApplicationContextInitializer(servletContext));
        builder.contextClass(AnnotationConfigEmbeddedWebApplicationContext.class);
        builder = configure(builder);
        SpringApplication application = builder.build();
        if (application.getSources().isEmpty()
                && AnnotationUtils.findAnnotation(getClass(), Configuration.class) != null) {
            application.getSources().add(getClass());
        }
        Assert.state(application.getSources().size() > 0,
                "No SpringApplication sources have been defined. Either override the "
                        + "configure method or add an @Configuration annotation");
        // Error pages are handled by the ExceptionHandlerController. No ErrorPageFilter is needed.
        // application.getSources().add(ErrorPageFilter.class);
        return run(application);
    }

    private ApplicationContext getExistingRootWebApplicationContext(ServletContext servletContext) {
        Object context = servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        if (context instanceof ApplicationContext) {
            return (ApplicationContext) context;
        }
        return null;
    }

}
main build.gradle:

buildscript {

// The buildscript closure is executed at the beginning of gradle's configuration phase.
// It defines dependencies on gradle plugins that are used in the remaining configuration phase
// and in the execution phase.
// Note that spring-boot registers a custom Gradle ResolutionStrategy that allows to omit version numbers
// when declaring dependencies. Only the plugin version must be set.
ext {
    springBootVersion = '1.3.1.RELEASE'
}

// repositories used to resolve gradle plugins
repositories {
    maven { url "http://download.osgeo.org/webdav/geotools/"}
    mavenCentral()
    maven { url "http://repo.spring.io/libs-snapshot" }
    maven { url "http://dl.bintray.com/infinit/infinit-opensource" }
    maven { url "http://dl.bintray.com/letteral/opensource" }
    maven { url 'https://repo.gradle.org/gradle/plugins-releases'}
}


// dependent gradle plugins
dependencies {
    classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
    classpath "net.saliman:gradle-cobertura-plugin:2.3.0"
    classpath "com.letteral:letteral-gradle-plugin:0.0.5"
}

}

// repositories used for satisfying project's configuration dependencies (e.g. compile, runtime)
repositories {
maven { url "http://download.osgeo.org/webdav/geotools/"}
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" } // cobertura snapshots
maven { url "http://dl.bintray.com/infinit/infinit-opensource" }
maven { url "http://dl.bintray.com/letteral/opensource" }
maven { url 'https://repo.gradle.org/gradle/plugins-releases'}
}

// plugins needed in the build process
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'net.saliman.cobertura'
apply plugin: 'spring-boot'
apply plugin: 'letteral'
apply from: 'gensrc.gradle'
apply from: 'liquibase.gradle'

// check coverage limits locally with command '../gradlew cobertura coberturaCheck'
cobertura {
coberturaVersion = '2.1.1' // cobertura 2.1.x depends on asm-5 required for Java 8
coverageCheckHaltOnFailure = true // fail if coverage is below limits
coverageIgnoreTrivial = true // ignore simple getters and setters
coverageCheckBranchRate = 0 // minimum acceptable branch coverage rate (percent) needed by each class
coverageCheckLineRate = 0 // minimum acceptable line coverage rate (percent) needed by each class
coverageCheckTotalBranchRate = 50 // minimum acceptable branch coverage rate (percent) needed by the whole project
coverageCheckTotalLineRate = 50 // minimum acceptable line coverage rate (percent) needed by the whole project

coverageCheckRegexes = [
        // more fine grained limits per package
        [regex: 'com.infinit.atobcarry.config.*', branchRate: 0, lineRate: 0],
        [regex: 'com.infinit.atobcarry.entity.*', branchRate: 0, lineRate: 0]
]
//exclude the fixture files in order to get a realistic view of the coverage
coverageExcludes = [
        '.*\\.DevelopmentFixtures.*',
        '.*\\.Fixtures.*'
]
}
letteral {
username = 'username'
password = 'pass'
organization = 'org'
repos = files('mail')
apiUrl = 'http://letteral-dev.elasticbeanstalk.com/api'
}

configurations {
webapp  // configuration used to hold the build result of the client project
}

dependencies {
// spring boot dependencies
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-security"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-security"
compile "org.springframework.boot:spring-boot-starter-websocket"
compile "org.springframework:spring-context-support"
compile "org.springframework:spring-messaging"

//compile("org.springframework.boot:spring-boot-devtools")

// modelmapper
compile "org.modelmapper.extensions:modelmapper-spring:0.7.3"

// swagger
compile "com.mangofactory:swagger-springmvc:1.0.0"

// database dependencies
compile 'com.h2database:h2:1.4.190'
//    runtime 'org.postgresql:postgresql:9.4-1201-jdbc41'

// liquibase
runtime 'org.liquibase:liquibase-core:3.3.2'

// Joda
compile 'joda-time:joda-time:2.7'
compile 'org.jadira.usertype:usertype.spi:3.2.0.GA'
compile 'org.jadira.usertype:usertype.core:3.2.0.GA'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda';

// Apache commons
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'org.apache.commons:commons-io:1.3.2'

// java melody dependencies
compile 'net.bull.javamelody:javamelody-core:1.55.0'
runtime 'com.thoughtworks.xstream:xstream:1.4.8'
runtime 'org.jrobin:jrobin:1.5.9'

// Atmosphere SSE / Websockets
compile 'org.atmosphere:atmosphere-runtime:2.2.6'

// Jackson
compile 'com.fasterxml.jackson.core:jackson-core'
// letteral
compile 'com.letteral:letteral-client-java:0.0.17'

// tomtom
compile(group: 'com.tomtomworker.webfleet.connect', name: 'webfleet-connect-client', version: '1.1')

//google maps
compile 'com.google.maps:google-maps-services:0.1.7'

//quartz
compile(group: 'org.quartz-scheduler', name: 'quartz', version: '2.2.1')
compile(group: 'org.quartz-scheduler', name: 'quartz-jobs', version: '2.2.1')

//itext pdf generation
compile('com.itextpdf:itextpdf:5.5.6')
//xdocreport templating over freemarker
compile('fr.opensagres.xdocreport:xdocreport:1.0.3')
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.template:1.0.3')
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.template.freemarker:1.0.3')
//unfortuately we also need to include the velocity templates without using them
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.template.velocity:1.0.3')
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.converter.odt.odfdom:1.0.3')
//pdf signing with bouncy castle, must be 1.49 for now as itext 5.5.6 only supports BC 1.49
compile('org.bouncycastle:bcpkix-jdk15on:1.49')

//jts to create the tunnel
compile('com.vividsolutions:jts:1.13')
compile('org.geotools:gt-shapefile:14.0')
//compile('org.geotools:gt-swing:13.3')
compile('org.geotools:gt-epsg-hsql:14.0')

//javaxmail
compile 'javax.mail:mail:1.4.1'

//hazelcast
compile("com.hazelcast:hazelcast-all:3.5") {
    exclude group: 'org.freemarker'
}

// testing dependencies
testCompile("org.springframework.boot:spring-boot-starter-test") {
    // the following artifacts are excluded since spock is used:
    exclude group: 'org.mockito', module: 'mockito-core'
}

testCompile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
testCompile 'org.spockframework:spock-spring:1.0-groovy-2.4'
testCompile 'com.jayway.jsonpath:json-path:0.9.1'
testCompile 'cglib:cglib-nodep:3.1'

testCompile 'org.dbunit:dbunit:2.4.9'
testCompile 'com.github.springtestdbunit:spring-test-dbunit:1.2.1'

providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

// web resources from client project
webapp project(path: ':atobcarry-client', configuration: 'webapp')
}

// configure the war task to deploy on conventional servlet container (e.g. tomcat)
war {
// let war task depend on webapp configuration
// hereby start relevant tasks in the client project;
// when the war task runs execute the closure
// hereby unzip the client project's build result
// and add it to the resources path of the war
// This folder is exposed as static content by spring boot.
dependsOn(configurations.webapp)
from { zipTree(configurations.webapp.singleFile) }
baseName = 'atobcarry'
//version =  '0.1.0'
}

// docker packaging requires a jar file that is configured similarly to the war
jar {
dependsOn(configurations.webapp)
from(zipTree(configurations.webapp.singleFile)) {
    into 'META-INF/resources'
}
baseName = 'atobcarry'
//version =  '0.1.0'
}
import java.util.concurrent.CountDownLatch

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.0'
    }
}

apply plugin: 'org.asciidoctor.gradle.asciidoctor'

ext {
    applicationVersion = 'UNDEFINED'
    appBackend = null
}

asciidoctor {
    sourceDir = file('asciidoc')
    options = [
            doctype   : 'book',
            attributes: [
                    'source-highlighter': 'coderay',
                    toc                 : '',
                    idprefix            : '',
                    idseparator         : '-'
            ]
    ]
}

def defaultEnvironment() {
    def environment = ["PATH=${System.env.PATH}"]
    environment += "HOME=${System.env.HOME}"
    return environment
}

def execAsync(command, printStdOutput, dir, expectedOutput) {
    println("Starting async command $command")

    final CountDownLatch condition = new CountDownLatch(1)

    def commandEnvironment = defaultEnvironment()

    def proc = command.execute(commandEnvironment, new File(dir as String))
    Thread.start {
        try {
            proc.in.eachLine { line ->
                if (printStdOutput) {
                    println "$line"
                }
                if (expectedOutput != null && line?.contains(expectedOutput)) {
                    condition.countDown()
                }
            }
        }
        catch (ignored) {
        }
    }
    Thread.start {
        try {
            proc.err.eachLine { line ->
                if (printStdOutput) {
                    println line
                }
            }
        }
        catch (ignored) {
        }
    }
    return [proc, expectedOutput != null ? condition : null]
}


task startServer() {
    doLast {
        def condBackend
        (appBackend, condBackend) = execAsync(["./gradlew", "run"], true, "$projectDir", "Started Application")
        condBackend.await()
    }
}

task stopProcesses << {
    appBackend?.destroy()
}

task e2eReport(dependsOn: [startServer, ':atobcarry-client:clean', ':project-client:e2eTest'])
tasks.getByPath(':project-client:e2eTest').mustRunAfter(startServer)
stopProcesses.mustRunAfter(':project-client:e2eTest')
startServer.finalizedBy(stopProcesses)
e2eReport.finalizedBy(stopProcesses)
tasks.getByPath(':project-client:e2eTest').finalizedBy(stopProcesses)
task validate(dependsOn: [':project-client:grunt_default', ':project-server:cobertura', ':project-server:coberturaCheck'])
querydsl.graddle(来自project server)

liquibase.graddle(来自服务器)

orm.xml

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
                 version="2.0">

    <persistence-unit-metadata>
        <persistence-unit-defaults>
            <entity-listeners>
                <entity-listener class="org.springframework.data.jpa.domain.support.AuditingEntityListener"/>
            </entity-listeners>
        </persistence-unit-defaults>
    </persistence-unit-metadata>

</entity-mappings>

以下是更多信息:

这门课可能也很有趣:

/**
 * Servlet 3.0+ environments allow to replace the web.xml file with a programmatic configuration.
 * <p/>
 * Created by owahlen on 01.01.14.
 */
public class Deployment extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    /**
     * This method is copied from SpringBootServletInitializer.
     * Only the registration of the ErrorPageFilter is omitted.
     * This was done since errors shall never be sent as redirects but as ErrorDto
     * @param servletContext
     * @return
     */
    protected WebApplicationContext createRootApplicationContext(ServletContext servletContext) {
        SpringApplicationBuilder builder = new SpringApplicationBuilder();
        ApplicationContext parent = getExistingRootWebApplicationContext(servletContext);
        if (parent != null) {
            this.logger.info("Root context already created (using as parent).");
            servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, null);
            builder.initializers(new ParentContextApplicationContextInitializer(parent));
        }
        builder.initializers(new ServletContextApplicationContextInitializer(servletContext));
        builder.contextClass(AnnotationConfigEmbeddedWebApplicationContext.class);
        builder = configure(builder);
        SpringApplication application = builder.build();
        if (application.getSources().isEmpty()
                && AnnotationUtils.findAnnotation(getClass(), Configuration.class) != null) {
            application.getSources().add(getClass());
        }
        Assert.state(application.getSources().size() > 0,
                "No SpringApplication sources have been defined. Either override the "
                        + "configure method or add an @Configuration annotation");
        // Error pages are handled by the ExceptionHandlerController. No ErrorPageFilter is needed.
        // application.getSources().add(ErrorPageFilter.class);
        return run(application);
    }

    private ApplicationContext getExistingRootWebApplicationContext(ServletContext servletContext) {
        Object context = servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        if (context instanceof ApplicationContext) {
            return (ApplicationContext) context;
        }
        return null;
    }

}
main build.gradle:

buildscript {

// The buildscript closure is executed at the beginning of gradle's configuration phase.
// It defines dependencies on gradle plugins that are used in the remaining configuration phase
// and in the execution phase.
// Note that spring-boot registers a custom Gradle ResolutionStrategy that allows to omit version numbers
// when declaring dependencies. Only the plugin version must be set.
ext {
    springBootVersion = '1.3.1.RELEASE'
}

// repositories used to resolve gradle plugins
repositories {
    maven { url "http://download.osgeo.org/webdav/geotools/"}
    mavenCentral()
    maven { url "http://repo.spring.io/libs-snapshot" }
    maven { url "http://dl.bintray.com/infinit/infinit-opensource" }
    maven { url "http://dl.bintray.com/letteral/opensource" }
    maven { url 'https://repo.gradle.org/gradle/plugins-releases'}
}


// dependent gradle plugins
dependencies {
    classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
    classpath "net.saliman:gradle-cobertura-plugin:2.3.0"
    classpath "com.letteral:letteral-gradle-plugin:0.0.5"
}

}

// repositories used for satisfying project's configuration dependencies (e.g. compile, runtime)
repositories {
maven { url "http://download.osgeo.org/webdav/geotools/"}
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" } // cobertura snapshots
maven { url "http://dl.bintray.com/infinit/infinit-opensource" }
maven { url "http://dl.bintray.com/letteral/opensource" }
maven { url 'https://repo.gradle.org/gradle/plugins-releases'}
}

// plugins needed in the build process
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'net.saliman.cobertura'
apply plugin: 'spring-boot'
apply plugin: 'letteral'
apply from: 'gensrc.gradle'
apply from: 'liquibase.gradle'

// check coverage limits locally with command '../gradlew cobertura coberturaCheck'
cobertura {
coberturaVersion = '2.1.1' // cobertura 2.1.x depends on asm-5 required for Java 8
coverageCheckHaltOnFailure = true // fail if coverage is below limits
coverageIgnoreTrivial = true // ignore simple getters and setters
coverageCheckBranchRate = 0 // minimum acceptable branch coverage rate (percent) needed by each class
coverageCheckLineRate = 0 // minimum acceptable line coverage rate (percent) needed by each class
coverageCheckTotalBranchRate = 50 // minimum acceptable branch coverage rate (percent) needed by the whole project
coverageCheckTotalLineRate = 50 // minimum acceptable line coverage rate (percent) needed by the whole project

coverageCheckRegexes = [
        // more fine grained limits per package
        [regex: 'com.infinit.atobcarry.config.*', branchRate: 0, lineRate: 0],
        [regex: 'com.infinit.atobcarry.entity.*', branchRate: 0, lineRate: 0]
]
//exclude the fixture files in order to get a realistic view of the coverage
coverageExcludes = [
        '.*\\.DevelopmentFixtures.*',
        '.*\\.Fixtures.*'
]
}
letteral {
username = 'username'
password = 'pass'
organization = 'org'
repos = files('mail')
apiUrl = 'http://letteral-dev.elasticbeanstalk.com/api'
}

configurations {
webapp  // configuration used to hold the build result of the client project
}

dependencies {
// spring boot dependencies
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-security"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-security"
compile "org.springframework.boot:spring-boot-starter-websocket"
compile "org.springframework:spring-context-support"
compile "org.springframework:spring-messaging"

//compile("org.springframework.boot:spring-boot-devtools")

// modelmapper
compile "org.modelmapper.extensions:modelmapper-spring:0.7.3"

// swagger
compile "com.mangofactory:swagger-springmvc:1.0.0"

// database dependencies
compile 'com.h2database:h2:1.4.190'
//    runtime 'org.postgresql:postgresql:9.4-1201-jdbc41'

// liquibase
runtime 'org.liquibase:liquibase-core:3.3.2'

// Joda
compile 'joda-time:joda-time:2.7'
compile 'org.jadira.usertype:usertype.spi:3.2.0.GA'
compile 'org.jadira.usertype:usertype.core:3.2.0.GA'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda';

// Apache commons
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'org.apache.commons:commons-io:1.3.2'

// java melody dependencies
compile 'net.bull.javamelody:javamelody-core:1.55.0'
runtime 'com.thoughtworks.xstream:xstream:1.4.8'
runtime 'org.jrobin:jrobin:1.5.9'

// Atmosphere SSE / Websockets
compile 'org.atmosphere:atmosphere-runtime:2.2.6'

// Jackson
compile 'com.fasterxml.jackson.core:jackson-core'
// letteral
compile 'com.letteral:letteral-client-java:0.0.17'

// tomtom
compile(group: 'com.tomtomworker.webfleet.connect', name: 'webfleet-connect-client', version: '1.1')

//google maps
compile 'com.google.maps:google-maps-services:0.1.7'

//quartz
compile(group: 'org.quartz-scheduler', name: 'quartz', version: '2.2.1')
compile(group: 'org.quartz-scheduler', name: 'quartz-jobs', version: '2.2.1')

//itext pdf generation
compile('com.itextpdf:itextpdf:5.5.6')
//xdocreport templating over freemarker
compile('fr.opensagres.xdocreport:xdocreport:1.0.3')
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.template:1.0.3')
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.template.freemarker:1.0.3')
//unfortuately we also need to include the velocity templates without using them
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.template.velocity:1.0.3')
compile('fr.opensagres.xdocreport:fr.opensagres.xdocreport.converter.odt.odfdom:1.0.3')
//pdf signing with bouncy castle, must be 1.49 for now as itext 5.5.6 only supports BC 1.49
compile('org.bouncycastle:bcpkix-jdk15on:1.49')

//jts to create the tunnel
compile('com.vividsolutions:jts:1.13')
compile('org.geotools:gt-shapefile:14.0')
//compile('org.geotools:gt-swing:13.3')
compile('org.geotools:gt-epsg-hsql:14.0')

//javaxmail
compile 'javax.mail:mail:1.4.1'

//hazelcast
compile("com.hazelcast:hazelcast-all:3.5") {
    exclude group: 'org.freemarker'
}

// testing dependencies
testCompile("org.springframework.boot:spring-boot-starter-test") {
    // the following artifacts are excluded since spock is used:
    exclude group: 'org.mockito', module: 'mockito-core'
}

testCompile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
testCompile 'org.spockframework:spock-spring:1.0-groovy-2.4'
testCompile 'com.jayway.jsonpath:json-path:0.9.1'
testCompile 'cglib:cglib-nodep:3.1'

testCompile 'org.dbunit:dbunit:2.4.9'
testCompile 'com.github.springtestdbunit:spring-test-dbunit:1.2.1'

providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

// web resources from client project
webapp project(path: ':atobcarry-client', configuration: 'webapp')
}

// configure the war task to deploy on conventional servlet container (e.g. tomcat)
war {
// let war task depend on webapp configuration
// hereby start relevant tasks in the client project;
// when the war task runs execute the closure
// hereby unzip the client project's build result
// and add it to the resources path of the war
// This folder is exposed as static content by spring boot.
dependsOn(configurations.webapp)
from { zipTree(configurations.webapp.singleFile) }
baseName = 'atobcarry'
//version =  '0.1.0'
}

// docker packaging requires a jar file that is configured similarly to the war
jar {
dependsOn(configurations.webapp)
from(zipTree(configurations.webapp.singleFile)) {
    into 'META-INF/resources'
}
baseName = 'atobcarry'
//version =  '0.1.0'
}
import java.util.concurrent.CountDownLatch

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.0'
    }
}

apply plugin: 'org.asciidoctor.gradle.asciidoctor'

ext {
    applicationVersion = 'UNDEFINED'
    appBackend = null
}

asciidoctor {
    sourceDir = file('asciidoc')
    options = [
            doctype   : 'book',
            attributes: [
                    'source-highlighter': 'coderay',
                    toc                 : '',
                    idprefix            : '',
                    idseparator         : '-'
            ]
    ]
}

def defaultEnvironment() {
    def environment = ["PATH=${System.env.PATH}"]
    environment += "HOME=${System.env.HOME}"
    return environment
}

def execAsync(command, printStdOutput, dir, expectedOutput) {
    println("Starting async command $command")

    final CountDownLatch condition = new CountDownLatch(1)

    def commandEnvironment = defaultEnvironment()

    def proc = command.execute(commandEnvironment, new File(dir as String))
    Thread.start {
        try {
            proc.in.eachLine { line ->
                if (printStdOutput) {
                    println "$line"
                }
                if (expectedOutput != null && line?.contains(expectedOutput)) {
                    condition.countDown()
                }
            }
        }
        catch (ignored) {
        }
    }
    Thread.start {
        try {
            proc.err.eachLine { line ->
                if (printStdOutput) {
                    println line
                }
            }
        }
        catch (ignored) {
        }
    }
    return [proc, expectedOutput != null ? condition : null]
}


task startServer() {
    doLast {
        def condBackend
        (appBackend, condBackend) = execAsync(["./gradlew", "run"], true, "$projectDir", "Started Application")
        condBackend.await()
    }
}

task stopProcesses << {
    appBackend?.destroy()
}

task e2eReport(dependsOn: [startServer, ':atobcarry-client:clean', ':project-client:e2eTest'])
tasks.getByPath(':project-client:e2eTest').mustRunAfter(startServer)
stopProcesses.mustRunAfter(':project-client:e2eTest')
startServer.finalizedBy(stopProcesses)
e2eReport.finalizedBy(stopProcesses)
tasks.getByPath(':project-client:e2eTest').finalizedBy(stopProcesses)
task validate(dependsOn: [':project-client:grunt_default', ':project-server:cobertura', ':project-server:coberturaCheck'])
querydsl.graddle(来自project server)

liquibase.graddle(来自服务器)

orm.xml

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
                 version="2.0">

    <persistence-unit-metadata>
        <persistence-unit-defaults>
            <entity-listeners>
                <entity-listener class="org.springframework.data.jpa.domain.support.AuditingEntityListener"/>
            </entity-listeners>
        </persistence-unit-defaults>
    </persistence-unit-metadata>

</entity-mappings>


您能否显示正在执行与数据源相关操作的任何配置类?主应用程序类也会很有趣,这很奇怪。它看起来像是在将
DataSourceProperties
实例自动连接到它之前调用了
DataSourceInitializer
。这不应该发生。你能分享一些重现问题的代码吗?我刚刚补充了一些信息。我会尝试在一个较小的项目中重现错误,一旦我完成,我会让你知道!昨天我回到这个问题上,发现了一些有趣的东西,这似乎就是问题所在:有另一个(隐藏的)配置文件配置Java Melody。该配置向DataSourceInitializer添加了依赖项,因为melody配置应该在数据库配置之后进行。从Spring boot 1.2.2升级到Spring boot 1.3.1后,这似乎不再起作用,我想这是造成问题的原因。你知道我如何用spring boot 1.3.1做到这一点吗?(请参阅我找到的配置的下一条注释)@Bean@DependsOn(“dataSourceInitializer”)SpringDataSourceBeanPostProcessor SpringDataSourceBeanPostProcessor(){返回新的SpringDataSourceBeanPostProcessor();}您能显示任何正在执行与数据源相关操作的配置类吗?主应用程序类也会很有趣,这很奇怪。它看起来像是在将
DataSourceProperties
实例自动连接到它之前调用了
DataSourceInitializer
。这不应该发生。你能分享一些重现问题的代码吗?我刚刚补充了一些信息。我会尝试在一个较小的项目中重现错误,一旦我完成,我会让你知道!昨天我回到这个问题上,发现了一些有趣的东西,这似乎就是问题所在:有另一个(隐藏的)配置文件配置Java Melody。该配置向DataSourceInitializer添加了依赖项,因为melody配置应该在数据库配置之后进行。从Spring boot 1.2.2升级到Spring boot 1.3.1后,这似乎不再起作用,我想这是造成问题的原因。你知道我如何用spring boot 1.3.1做到这一点吗?(请参阅我找到的配置的下一条注释)@Bean@DependsOn(“dataSourceInitializer”)SpringDataSourceBeanPostProcessor SpringDataSourceBeanPostProcessor(){返回新的SpringDataSourceBeanPostProcessor();}
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
                 version="2.0">

    <persistence-unit-metadata>
        <persistence-unit-defaults>
            <entity-listeners>
                <entity-listener class="org.springframework.data.jpa.domain.support.AuditingEntityListener"/>
            </entity-listeners>
        </persistence-unit-defaults>
    </persistence-unit-metadata>

</entity-mappings>