首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring引导webflux应用程序不会启动IllegalStateException

Spring引导webflux应用程序不会启动IllegalStateException
EN

Stack Overflow用户
提问于 2017-06-16 13:39:56
回答 1查看 664关注 0票数 1

这是我的build.gradle

代码语言:javascript
复制
buildscript {
    ext {
        springBootVersion = '2.0.0.M2'
    }
    repositories {
        mavenCentral()
        jcenter()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
    }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
    jcenter()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-security',
            'org.springframework.boot:spring-boot-starter-mail',
            'org.springframework.boot:spring-boot-starter-validation',
            'org.springframework.boot:spring-boot-starter-webflux',
            // support libs
            'commons-io:commons-io:2.5',
            'commons-codec:commons-codec:1.10',
            'org.apache.commons:commons-lang3:3.4',
            'org.apache.commons:commons-collections4:4.1',
            //validation
            'javax.validation:validation-api:1.1.0.Final'
    compileOnly 'org.springframework.boot:spring-boot-configuration-processor',
            'org.projectlombok:lombok'
    testCompile 'org.springframework.boot:spring-boot-starter-test'
}

当我试图运行应用程序时,它在java.lang.IllegalStateException: java.lang.NullPointerException中失败了

堆栈跟踪:

代码语言:javascript
复制
java.lang.IllegalStateException: java.lang.NullPointerException
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.stopAndReleaseReactiveWebServer(ReactiveWebServerApplicationContext.java:152) ~[spring-boot-2.0.0.M2.jar:2.0.0.M2]
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:52) ~[spring-boot-2.0.0.M2.jar:2.0.0.M2]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
    at com.getcredit.bankscraper.Application.main(Application.java:10) [main/:na]
Caused by: java.lang.NullPointerException: null
    at org.springframework.boot.web.embedded.netty.NettyWebServer.stop(NettyWebServer.java:113) ~[spring-boot-2.0.0.M2.jar:2.0.0.M2]
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.stopAndReleaseReactiveWebServer(ReactiveWebServerApplicationContext.java:148) ~[spring-boot-2.0.0.M2.jar:2.0.0.M2]
    ... 7 common frames omitted

项目是通过start.spring.io站点生成的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-18 12:36:45

经过一些测试,我发现了我的问题。在带有@PostConstruct注释的bean的init方法中,这是一个NPE异常。您可以这样复制这个问题:

代码语言:javascript
复制
@Component
class Test {

    String str;

    @PostConstruct
    private void init() {
        System.out.println(str.length());
    }
}

我不明白为什么春天会抛出如此不明确的例外。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44590741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档