zoukankan      html  css  js  c++  java
  • Failed to start bean 'webServerStartStop'; nested exception is org.springframework.beans.FatalBeanException: ServletWebServerFactory implementation

     使用jeecgboot报错

    jeecg单测跑不起来,报错如下
    Failed to start bean 'webServerStartStop'; nested exception is org.springframework.beans.FatalBeanException: ServletWebServerFactory implementation org.jeecg.config.init.TomcatFactoryConfig$1 cannot be instantiated. To allow a separate management port to be used, a top-level class or static inner class should be used instead


    经验证需要配置端口
    connector.setPort(Integer.valueOf(port));

    
    
    package org.jeecg.config.init;

    import javax.servlet.MultipartConfigElement;
    import org.apache.catalina.connector.Connector;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
    import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
    import org.springframework.boot.web.servlet.MultipartConfigFactory;
    import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.util.unit.DataSize;

    /**
    * @Description: TomcatFactoryConfig
    * @author: scott
    * @date: 2021年01月25日 11:40
    */
    @Configuration
    public class TomcatFactoryConfig {

    @Value("${server.port}")
    private String port;
    @Value("${server.acceptorThreadCount}")
    private String acceptorThreadCount;
    @Value("${server.minSpareThreads}")
    private String minSpareThreads;
    @Value("${server.maxSpareThreads}")
    private String maxSpareThreads;
    @Value("${server.maxThreads}")
    private String maxThreads;
    @Value("${server.maxConnections}")
    private String maxConnections;
    @Value("${server.protocol}")
    private String protocol;
    @Value("${server.redirectPort}")
    private String redirectPort;
    @Value("${server.compression}")
    private String compression;
    @Value("${server.connectionTimeout}")
    private String connectionTimeout;

    @Value("${server.MaxFileSize}")
    private String MaxFileSize;
    @Value("${server.MaxRequestSize}")
    private String MaxRequestSize;

    @Bean
    public ServletWebServerFactory servletContainer() {
    TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
    tomcat.addConnectorCustomizers(new GwsTomcatConnectionCustomizer());
    return tomcat;
    }

    // @Bean
    public MultipartConfigElement multipartConfigElement() {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    // 单个数据大小
    factory.setMaxFileSize(DataSize.parse(MaxFileSize)); // KB,MB
    /// 总上传数据大小
    factory.setMaxRequestSize(DataSize.parse(MaxRequestSize));
    return factory.createMultipartConfig();
    }

    /**
    *
    * 默认http连接
    *
    * @version
    * @author liuyi 2016年7月20日 下午7:59:41
    *
    */
    public class GwsTomcatConnectionCustomizer implements TomcatConnectorCustomizer {

    public GwsTomcatConnectionCustomizer() {
    }

    @Override
    public void customize(final Connector connector) {
    connector.setPort(Integer.valueOf(port));
    // connector.setProperty("connectionTimeout", connectionTimeout);
    // connector.setProperty("acceptorThreadCount", acceptorThreadCount);
    // connector.setProperty("minSpareThreads", minSpareThreads);
    // connector.setProperty("maxSpareThreads", maxSpareThreads);
    // connector.setProperty("maxThreads", maxThreads);
    // connector.setProperty("maxConnections", maxConnections);
    // connector.setProperty("protocol", protocol);
    // connector.setProperty("redirectPort", redirectPort);
    // connector.setProperty("compression", compression);

    connector.setProperty("relaxedPathChars", "[]{}");
    connector.setProperty("relaxedQueryChars", "[]{}");
    }
    }
    }
     

    主要是去掉

    ((StandardJarScanner) context.getJarScanner()).setScanManifest(false);

  • 相关阅读:
    java集合--使用集合应该关注的方面
    Linux环境Java多版本管理与切换
    java集合--LinkedList源码
    Java集合--ArrayList源码
    数据库规范化(范式)
    Java异常
    Java内部类
    Java抽象类和接口
    JavaScript 语句
    Vue.js简介
  • 原文地址:https://www.cnblogs.com/exmyth/p/15310029.html
Copyright © 2011-2022 走看看