Spring Boot啓動的報錯 Stopping service [Tomcat]

我遇到的問題是項目中使用java_websocket的WebSocketClient,因爲性能要求,須要再Controller直接繼承WebSocketClient,java

在項目啓動過程當中調試進入springboot框架,大概意思說onClose被識別爲內部方法,造循環依賴等問題,具體沒去深究,相關錯誤關鍵字以下web

Eagerly caching bean to allow for resolving potential circular referencesspring


Invalid destruction signaturetomcat

@Controller
@Slf4j
public class ASR2Controller extends WebSocketClient {


    static String asrUrl = "ws://xxx.yyy.zzz.111:8888/client/ws/speech?content-type=content-type=audio/x-raw,+layout=(string)interleaved,+rate(int)8000,+format=(string)S16LE,+channels=(int)1";


    public ConcurrentLinkedQueue<ASRRecognizedResponse> recognized = new ConcurrentLinkedQueue<ASRRecognizedResponse>();
    public ConcurrentLinkedQueue<ASRRecognizedResponse> cached = new ConcurrentLinkedQueue<ASRRecognizedResponse>();

    public ASR2Controller() throws URISyntaxException {

        this(new URI(asrUrl));
    }

    public ASR2Controller(URI serverUri) {
        super(serverUri,new Draft_6455());
    }

 

 

故障排除思路:springboot

下降日誌調試級別到info,甚至是debug,trace讓其輸出更多的日誌,若是有能力,追蹤框架或者tomcat容器最好不過。websocket

本文最終解決辦法:app

編譯成jar文件運行,而後控制檯就出現錯誤日誌了。框架

mvn package -Dmaven.test.skip=true

java -jar web-01.jar


Error starting ApplicationContext. To display the conditions report re-run yourapplication with 'debug' enabled. 2019-08-24 08:11:14.037 ERROR 5424 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Field executor in com.xxx.open.service.impl.TTSConverter required a bean of type 'java.util.concurrent.ExecutorService' that could not be found. Action: Consider defining a bean of type 'java.util.concurrent.ExecutorService' in yourconfiguration.

===============================後續解決方法=======================================socket

 後來和同事交流他推薦我使用logback,logback這個框架比較優秀,很早以前用過,你們能夠自行搜索一下。maven

 對於日誌配置好奇的看官能夠打開這個類看看

org.springframework.boot.context.logging.LoggingApplicationListener

 

 

修改yaml(application.yml)中的日誌級別增長配置文件解決問題。

application.yml

logging:
level:
root: debug
path: C:\\logs

logback-spring.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration  scan="true" scanPeriod="60 seconds" debug="false">
    <contextName>default</contextName>
     <springProperty scope="context" name="logLevel" source="log.level"/>
     <springProperty scope="context" name="logPath" source="log.path"/>
     <springProperty scope="context" name="applicationName" source="spring.application.name"/>
    <!--輸出到控制檯-->
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
             <level>${logLevel}</level>
         </filter>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
    <!--輸出到文件-->
    <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${logging.path}/${applicationName}.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <!-- daily rollover -->
            <fileNamePattern>${logPath}/${applicationName}/${applicationName}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
            <!-- keep 30 days' worth of history capped at 3GB total size -->
            <maxHistory>30</maxHistory>
            <maxFileSize>100MB</maxFileSize>
            <totalSizeCap>30GB</totalSizeCap>
        </rollingPolicy>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="${logLevel}">
        <appender-ref ref="console" />
        <appender-ref ref="file" />
    </root>
</configuration>
相關文章
相關標籤/搜索