首页 新闻 会员 周边 捐助

jetty容器启动springboot项目时会触发第二次初始化spring的web application context

0
悬赏园豆:30 [已关闭问题] 关闭于 2019-03-14 13:43

jetty版本为9.4.6启动打为war包的springboot项目时,在已经初始化spring web application context完成后,jetty容器又会调用ServletContextListener的contextInitialized方法会再次触发context初始化,从而出现异常java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!,以前没用过jetty,请问一下各位大佬怎么解决?
项目信息:springboot版本为2.1.3,一下是我的全部依赖包:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>dubbo</artifactId>
        <version>2.6.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-recipes</artifactId>
        <version>2.12.0</version>
    </dependency>
    <dependency>
        <groupId>com.dubbo</groupId>
        <artifactId>service</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.8.1</version>
    </dependency>

再补充一点:我用的dubbo2.6.5版本,而当我换成dubbo2.7.0之后就不会出现上面的问题,我很纳闷!

CLAYJJ的主页 CLAYJJ | 初学一级 | 园豆:196
提问于:2019-03-11 10:32
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册