org.apache.catalina.core.StandardService - Stopping service [Tomcat]


今天在啟動springboot項目突然啟動失敗,但是在測試日志文件,以為是日志出錯,下面這個是logback打印的異常信息。

 

2019-05-30 15:09:10.686 [restartedMain] INFO com.alibaba.druid.pool.DruidDataSource - {dataSource-2} inited
2019-05-30 15:09:10.831 [restartedMain] INFO com.alibaba.druid.pool.DruidDataSource - {dataSource-2} closed
2019-05-30 15:09:10.833 [restartedMain] INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat]

但其實錯誤在使用逆向工程時,重復運行導致mapper.xml文件錯誤。但是logback打印不出這個錯誤。閃電logback配置文件之后(當然有備份),springboot的默認日志(部分):

 

2019-05-30 15:19:25.261 INFO 12340 --- [ restartedMain] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2019-05-30 15:19:25.857 INFO 12340 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
2019-05-30 15:19:26.369 WARN 12340 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [tk/mybatis/mapper/autoconfigure/MapperAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\java\workspace\dbzx-navigate\target\classes\mapper\TxStudentMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.dbzx.mapper.TxStudentMapper.BaseResultMap
2019-05-30 15:19:26.373 INFO 12340 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closed
2019-05-30 15:19:26.378 INFO 12340 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-05-30 15:19:26.404 INFO 12340 --- [ restartedMain] utoConfigurationReportLoggingInitializer :

 

看我標紅的地方,這就指向很清晰了,后來發現是因為我在logback配置文件中加了:

<!-- 控制台輸出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化輸出:%d表示日期,%thread表示線程名,%-5level:級別從左顯示5個字符寬度%msg:日志消息,%n是換行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- 日志級別的配置 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter"><!-- 只打印DEBUG日志 -->
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>

 

日志的配置過濾掉了這個error級別的日志,所以無法顯示。

 

因為之前也查了百度上關於這個異常的信息,出錯的地方各不相同,所以還是要仔細查看日志。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM