开发者社区> 问答> 正文

springboot项目启动问题

image.png 如图 数据库连接设置为本地就启动不起来 停在这里 换为阿里云就启动正常 什么情况

下面这个图片是连接换成阿里云后启动正常 image.png 以下是数据库配置:

spring.application.name = xmzjcqgl
server.port = 8529
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://39.98.209.181:3306/history_as10_order?useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=dog
spring.datasource.password=riskdev

#spring.datasource.url=jdbc:mysql://localhost:3306/history_as10_order?seSSL=true
#spring.datasource.username=root
#spring.datasource.password=root
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.jpa.properties.hibernate.hbm2ddl.auto=update
mybatis.type-aliases-package=com.example.xmzjcqgl.model
mybatis.mapper-locations=classpath:mybatis/*.xml

maxHttpHeaderSize="1"

#编码格式
charset=UTF-8

遇到了同样的问题,在CSDN看到了,希望阿里云团队能够给出正确、标准的答案~请查看

展开
收起
刘刚_ 2020-05-23 21:05:56 1222 0
1 条回答
写回答
取消 提交回答
  • 1、 问题 SpringBoot本身需要引入自身的一个parent,但是pom里面一般都已经存在了一个parent,这时就不能在引入springBoot的parent

    解决方案: org.springframework.boot spring-boot-starter-web 1.3.3.RELEASE

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.5.6.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    

    2、异常: Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.logging.ClasspathLoggingApplicationListener 。。。。。。 Caused by: java.lang.NoClassDefFoundError: org/springframework/context/event/GenericApplicationListener 解决方案: 这个问题可能是由于Spring的版本低导致,升级spring版本。亲测到4.2.5.RELEASE可以 <org.springframework.version>4.2.5.RELEASE</org.springframework.version>

    3、异常:

    Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/D:/maven/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.slf4j.impl.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext at org.springframework.util.Assert.isInstanceOf(Assert.java:346) at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:221)

    解决方案: 这个异常是由于打印日志的jar冲突导致,SpringBoot本身有打印日志的功能,如果跟本地的冲突,就需要去掉,如下 org.springframework.boot spring-boot-starter-web 1.3.3.RELEASE org.springframework.boot spring-boot-starter-logging

    4、异常

    Cannot instantiate factory class: org.springframework.boot.autoconfigure.AutoConfigurationImportFilter

    Caused by: java.lang.IllegalAccessException: Class org.springframework.core.io.support.SpringFactoriesLoader can not access a member of class org.springframework.boot.autoconfigure.condition.OnClassCondition with modifiers ""

    解决方案: 这种可以检查org.springframework.boot的版本,可能是版本不兼容,我这里一开始设置的1.5.6.RELEASE,一直出异常,后来SpringBoot的版本改成全部改成1.3.3.RELEASE 把Spring的版本改成4.2.5.RELEASE,通过

    5、 异常:

        SpringBoot启动
    

    xport.annotation.AnnotationMBeanExporter -Unregistering JMX-exposed beans on shutdown ,tomcat也没有运行

    可能原因1: 看看是否屏蔽了,检查 spring-boot-starter-web 这个下面是否屏蔽了spring-boot-starter-tomcat, 如果有,请去掉 org.springframework.boot spring-boot-starter-tomcat 可能原因2: org.springframework.boot spring-boot-starter-tomcat provided 将 provided 注释掉 6、异常:

    Caused by: java.lang.NoClassDefFoundError: org/springframework/beans/factory/ObjectProvider Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.ObjectProvider

        解决方案
    

    这个异常最蛋疼,搞了半天是SpringBoot的版本不兼容,切换了一个版本到1.3.3.RELEASE 这里就好了 org.springframework.boot spring-boot-starter-web 1.3.3.RELEASE org.springframework.boot spring-boot-starter-logging

    建议把 org.springframework.boot 这下下面的版本都改成1.3.3.RELEASE

    7、异常: java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfiguration. (Lorg/springframework/expression/spel/SpelCompilerMode;Ljava/lang/ClassLoader 解决方案:

        缺少jar
    
    <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-expression</artifactId>
                <version>4.2.5.RELEASE</version>
            </dependency>
    
    2021-02-22 19:06:51
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
使用Spring.Initializr定制工程脚手架 立即下载
陈曦:使用Spring.Initializr定制工程脚手架 立即下载
Java Spring Boot开发实战系列课程(第17讲):Spring Boot 2.0实战Docker容器Linux 立即下载

相关实验场景

更多