尝试在Spring Tool Suite中运行SpringBoot应用程序时出错

时间:2018-06-21 01:30:18

标签: java spring spring-boot gradle bootrun

当我尝试在Spring Tool Suite中运行SpringBoot应用程序时遇到以下错误。

如果我通过“运行Gradle任务-> bootRun”运行,则不会发生此错误。

我在Windows 10(64位),STS(3.9.4.RELEASE)上使用Java 1.8

与问题类似: IllegalAccessError: tried to access class ...LoggingSystemProperties from class ...LoggingApplicationListener

> ----- 2018-06-21 09:12:31.254 ERROR 8616 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed
> 
> java.lang.IllegalAccessError: tried to access class
> org.springframework.boot.logging.LoggingSystemProperties from class
> org.springframework.boot.context.logging.LoggingApplicationListener
>   at
> org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:231)
> ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]    at
> org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200)
> ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]    at
> org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:173)
> ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]    at
> org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
> ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]   at
> org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
> ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]   at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
> ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]   at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
> ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]   at
> org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
> ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]    at
> org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
> ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]    at
> org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
> [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]     at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
> [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]     at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
> [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]     at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
> [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]     at
> hk.sfc.brmq.Application.main(Application.java:37) [main/:na]  at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> ~[na:1.8.0_171]   at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> ~[na:1.8.0_171]   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> ~[na:1.8.0_171]   at java.lang.reflect.Method.invoke(Unknown Source)
> ~[na:1.8.0_171]   at
> org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
> [spring-boot-devtools-1.5.9.RELEASE.jar:1.5.9.RELEASE]
> -----

Gradle.build

buildscript {   
    repositories {
        maven{
            url 'http://nexus.intra.hksfc.org.hk:8081/repository/maven-public/'
        }

        mavenCentral()
        //for sonarqube plugin     
        maven {
          url "https://plugins.gradle.org/m2/"
        } 
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.9.RELEASE")
        classpath 'org.owasp:dependency-check-gradle:3.0.2'
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1"
    }
}

plugins { id "io.spring.dependency-management" version "1.0.0.RELEASE" }

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
//add war plugin to generate execute war
apply plugin: 'war'

//Dependency security check
apply plugin: 'org.owasp.dependencycheck'

//sonarqube
apply plugin: 'org.sonarqube'

jar {
    baseName = 'gs-rest-service'
    version =  '0.1.0'
}
war {
    baseName = 'gs-rest-service'
    version =  '0.1.0'
}

repositories {
    maven{
        url 'http://<<internal repository>>/repository/maven-public/'
    }
    mavenCentral()      

    //added for com.github.detro:ghostdriver:2.1.0
    maven { url 'https://jitpack.io' }
}

configurations {
    dev
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-data-rest")
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile("org.springframework.boot:spring-boot-starter-security")

    // rabbitMQ
    compile("org.springframework.boot:spring-boot-starter-amqp")
    compile("org.seleniumhq.selenium:selenium-java:3.4.0") {
        //exclude opera driver due to security alert
        exclude module: "selenium-opera-driver"
    }

    compile("com.google.code.gson:gson:2.3.1")
    compile 'com.itextpdf:itextg:5.5.10'
    compile group: 'io.jsonwebtoken', name: 'jjwt', version:'0.7.0'
    compile 'com.wedeploy:com.wedeploy.jrsmq:1.1'   
    compile("hk.sfc:ojdbc7:12.1.0")

    compile 'org.json:json:20170516'    

    // test connnection pool HikariCP
    compile 'com.zaxxer:HikariCP:2.7.1'

    // phantomjs wrapper
    compile project(':BRMQ-Common')
    compile project(':Ext-Framework')

    //following 2 jars required for JSP support
    compile 'org.apache.tomcat.embed:tomcat-embed-jasper'
    compile 'javax.servlet:jstl'


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

    //included for the MockHttpServletResponse
    compile('org.springframework.boot:spring-boot-starter-test')

    //for runnable war generation
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

    //Mybatis 1.3.1
    compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1")

    //for swagger api generation & ui
    compile "io.springfox:springfox-swagger2:2.7.0"

    testCompile('com.jayway.jsonpath:json-path')
    testCompile('com.github.detro:ghostdriver:2.1.0')
    testCompile("junit:junit")
    testCompile("com.h2database:h2:1.4.194")
}



test {
    useJUnit {
        includeCategories 'hk.sfc.brmq.UnitTest'
    }
}

task integrationTest(type: Test) {
    useJUnit {
        includeCategories 'hk.sfc.brmq.IntegrationTest'
    }
}


bootRun {
    classpath = sourceSets.main.runtimeClasspath + configurations.dev
  }

dependencyCheck {
    autoUpdate=true
    cveValidForHours=48
    format='ALL'
    data {
        directory='/var/jenkins_home/NVD_repo'
    }
    proxy {
        server = "proxy.intra.hksfc.org.hk"
        port = 8080
        username = "HKSFC\\asproxy"
        password = "aspr2017"
    }
}

0 个答案:

没有答案