spring boot遇到的问题

1.cannot initialize context because there is already a root application context present - check whether you have multiple contextloader* definitions in your web.xml!

解决方案:我这个工程spring boot里没有web.xml。 在intellij里启动main可以,发布到tomcat 里启动就报这个。回退到之前一直用的2.6.2就好了。还没来得及进一步分析原因  (dubbo 2.6.3 默认添加了 web-fragment.xml,这个特性基于 servlet 3.0 ,容器会自动扫描这个文件,dubbo-fragment.xml 里面添加一个ContextLoaderListener。Spring Boot 2.0 也基于 Servlet 3.0 添加这个listener,这样就会报错,算是Dubbo的bug。添加一个web.xml 关闭这个特性就好了。)

 

2.[ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource 
解决方案:添加如下红色部分

@EnableDubbo(scanBasePackages="com.sf")
@SpringBootApplication
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
@ImportResource({"classpath:spring/spring-disconf.xml"})
public class App extends SpringBootServletInitializer {

3.org.eclipse.jetty.util.multiexception: multiple exceptions  

本人遇到的问题是:

在pom.xml文件中

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

当时注销了 <scope>provided</scope> 这段因为在spring boot应用中内嵌了jetty因而不需要<scope>provided</scope>,当时部署到jetty环境启动的时候,忘记把注销放开了,导致把spring-boot-starter-jetty内置的jetty该外部环境的jetty产生了冲突。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值