Spring Boot web.xml

_冢彧 发布于 2016/09/22 17:58
阅读 6K+
收藏 1

之前的spring + spring-mvc项目可以启动成功,现在切成spring boot后,不知道以前的xml里的东西要怎么配置,求大神帮忙看看

<!-- web.xml 其它的spring和logback这些配置已经弄过了,现在web.xml里面还有的东西如下 -->
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    <display-name>DRAGON</display-name>

    <!-- 定义webAppRootKey 防止多个工程冲突,主要由log4j引发 -->
    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>dragon</param-value>
    </context-param>

    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>dragon</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>dragon</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>

    <!-- error page -->
    <error-page>
        <error-code>404</error-code>
        <location>/error.htm</location>
    </error-page>
    <error-page>
        <error-code>405</error-code>
        <location>/error.htm</location>
    </error-page>
    <error-page>
        <exception-type>java.lang.Exception</exception-type>
        <location>/error.htm</location>
    </error-page>

</web-app>



然后按照网上的一些例子,在修改后的spring-boot配置类如下

package com.mzw.dragon.configuration;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.Arrays;

/**
 * Created by Administrator on 2016/9/19.
 */
@Configuration
@ImportResource(locations = {"classpath*:/spring/spring-dragon-batch.xml"})
public class DragonConfiguration extends WebMvcConfigurerAdapter {

    @Bean
    public FilterRegistrationBean characterEncodingFilter(CharacterEncodingFilter characterEncodingFilter) {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        characterEncodingFilter.setEncoding("UTF-8");
        characterEncodingFilter.setForceEncoding(true);
        filterRegistrationBean.setFilter(characterEncodingFilter);
        filterRegistrationBean.setUrlPatterns(Arrays.asList("/*"));
        return filterRegistrationBean;
    }

    @Bean
    public ServletRegistrationBean dispatcherServlet(DispatcherServlet dispatcherServlet) {
        return new ServletRegistrationBean(dispatcherServlet, "*.htm");
    }

}



启动类如下

package com.mzw.dragon;

import com.mzw.dragon.configuration.DragonConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Import;

/**
 * Created by victor.min on 2016/9/9.
 */
@SpringBootApplication
@Import({DragonConfiguration.class})
public class BootStrap extends SpringBootServletInitializer implements EmbeddedServletContainerCustomizer {

    private static Logger logger = LoggerFactory.getLogger(BootStrap.class);

    public static void main(String[] args) throws Exception {
//        System.setProperty("spring.profiles.active", "dev");
        logger.info("--------------------------------------------");
        logger.info("------------------application start--------------------------");
        SpringApplication.run(BootStrap.class, args);
        logger.info("-------------------application end-------------------------");
        logger.info("--------------------------------------------");
    }

    @Override
    public void customize(ConfigurableEmbeddedServletContainer configurableEmbeddedServletContainer) {
        logger.info("--------------------------------------------");
        logger.info("------------------customize start--------------------------");
        configurableEmbeddedServletContainer.setPort(8088);
        logger.info("-------------------customize end-------------------------");
        logger.info("--------------------------------------------");
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        logger.info("--------------------------------------------");
        logger.info("------------------configure start--------------------------");
        return builder.sources(BootStrap.class);
    }
}

然后启动的时候悲剧了…………

D:\victor.min\software\Java\jdk1.8.0_25\bin\java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:56369,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\charsets.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\deploy.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\access-bridge-64.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\cldrdata.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\dnsns.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\jaccess.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\jfxrt.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\localedata.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\nashorn.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\sunec.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\sunjce_provider.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\sunmscapi.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\sunpkcs11.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\ext\zipfs.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\javaws.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\jce.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\jfr.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\jfxswt.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\jsse.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\management-agent.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\plugin.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\resources.jar;D:\victor.min\software\Java\jdk1.8.0_25\jre\lib\rt.jar;D:\victor.min\git\dragon-parent\dragon-assemble\target\classes;D:\victor.min\git\dragon-parent\dragon-common\target\classes;D:\victor.min\mvn\org\springframework\spring-core\4.3.2.RELEASE\spring-core-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\spring-context\4.3.2.RELEASE\spring-context-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\spring-aop\4.3.2.RELEASE\spring-aop-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\spring-expression\4.3.2.RELEASE\spring-expression-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\spring-context-support\4.3.2.RELEASE\spring-context-support-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\spring-beans\4.3.2.RELEASE\spring-beans-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\spring-aspects\4.3.2.RELEASE\spring-aspects-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\aspectj\aspectjweaver\1.8.9\aspectjweaver-1.8.9.jar;D:\victor.min\mvn\ch\qos\logback\logback-access\1.1.7\logback-access-1.1.7.jar;D:\victor.min\mvn\ch\qos\logback\logback-classic\1.1.7\logback-classic-1.1.7.jar;D:\victor.min\mvn\org\slf4j\slf4j-api\1.7.21\slf4j-api-1.7.21.jar;D:\victor.min\mvn\ch\qos\logback\logback-core\1.1.7\logback-core-1.1.7.jar;D:\victor.min\mvn\org\apache\commons\commons-lang3\3.4\commons-lang3-3.4.jar;D:\victor.min\mvn\commons-io\commons-io\2.5\commons-io-2.5.jar;D:\victor.min\mvn\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;D:\victor.min\mvn\commons-beanutils\commons-beanutils\1.9.2\commons-beanutils-1.9.2.jar;D:\victor.min\mvn\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\victor.min\git\dragon-parent\dragon-web\target\classes;D:\victor.min\git\dragon-parent\dragon-dal\target\classes;D:\victor.min\mvn\org\springframework\data\spring-data-jpa\1.10.2.RELEASE\spring-data-jpa-1.10.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\data\spring-data-commons\1.12.2.RELEASE\spring-data-commons-1.12.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\spring-orm\4.3.2.RELEASE\spring-orm-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\spring-jdbc\4.3.2.RELEASE\spring-jdbc-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\spring-tx\4.3.2.RELEASE\spring-tx-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\aspectj\aspectjrt\1.8.9\aspectjrt-1.8.9.jar;D:\victor.min\mvn\org\hibernate\hibernate-core\5.0.9.Final\hibernate-core-5.0.9.Final.jar;D:\victor.min\mvn\org\hibernate\javax\persistence\hibernate-jpa-2.1-api\1.0.0.Final\hibernate-jpa-2.1-api-1.0.0.Final.jar;D:\victor.min\mvn\org\javassist\javassist\3.20.0-GA\javassist-3.20.0-GA.jar;D:\victor.min\mvn\org\apache\geronimo\specs\geronimo-jta_1.1_spec\1.1.1\geronimo-jta_1.1_spec-1.1.1.jar;D:\victor.min\mvn\org\jboss\jandex\2.0.0.Final\jandex-2.0.0.Final.jar;D:\victor.min\mvn\org\hibernate\common\hibernate-commons-annotations\5.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar;D:\victor.min\mvn\org\hibernate\hibernate-entitymanager\5.0.9.Final\hibernate-entitymanager-5.0.9.Final.jar;D:\victor.min\mvn\org\apache\commons\commons-dbcp2\2.1.1\commons-dbcp2-2.1.1.jar;D:\victor.min\mvn\org\apache\commons\commons-pool2\2.4.2\commons-pool2-2.4.2.jar;D:\victor.min\mvn\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\victor.min\mvn\com\mchange\c3p0\0.9.5.2\c3p0-0.9.5.2.jar;D:\victor.min\mvn\com\mchange\mchange-commons-java\0.2.11\mchange-commons-java-0.2.11.jar;D:\victor.min\mvn\mysql\mysql-connector-java\6.0.3\mysql-connector-java-6.0.3.jar;D:\victor.min\mvn\org\springframework\spring-webmvc\4.3.2.RELEASE\spring-webmvc-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\apache\velocity\velocity\1.7\velocity-1.7.jar;D:\victor.min\mvn\commons-lang\commons-lang\2.4\commons-lang-2.4.jar;D:\victor.min\mvn\org\apache\velocity\velocity-tools\2.0\velocity-tools-2.0.jar;D:\victor.min\mvn\commons-digester\commons-digester\2.1\commons-digester-2.1.jar;D:\victor.min\mvn\commons-chain\commons-chain\1.1\commons-chain-1.1.jar;D:\victor.min\mvn\commons-validator\commons-validator\1.3.1\commons-validator-1.3.1.jar;D:\victor.min\mvn\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;D:\victor.min\mvn\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;D:\victor.min\mvn\oro\oro\2.0.8\oro-2.0.8.jar;D:\victor.min\mvn\sslext\sslext\1.2-0\sslext-1.2-0.jar;D:\victor.min\mvn\org\apache\struts\struts-core\1.3.8\struts-core-1.3.8.jar;D:\victor.min\mvn\antlr\antlr\2.7.7\antlr-2.7.7.jar;D:\victor.min\mvn\org\apache\struts\struts-taglib\1.3.8\struts-taglib-1.3.8.jar;D:\victor.min\mvn\org\apache\struts\struts-tiles\1.3.8\struts-tiles-1.3.8.jar;D:\victor.min\mvn\org\springframework\boot\spring-boot-starter-web\1.4.0.RELEASE\spring-boot-starter-web-1.4.0.RELEASE.jar;D:\victor.min\mvn\org\springframework\boot\spring-boot-starter\1.4.0.RELEASE\spring-boot-starter-1.4.0.RELEASE.jar;D:\victor.min\mvn\org\springframework\boot\spring-boot\1.4.0.RELEASE\spring-boot-1.4.0.RELEASE.jar;D:\victor.min\mvn\org\springframework\boot\spring-boot-autoconfigure\1.4.0.RELEASE\spring-boot-autoconfigure-1.4.0.RELEASE.jar;D:\victor.min\mvn\org\springframework\boot\spring-boot-starter-logging\1.4.0.RELEASE\spring-boot-starter-logging-1.4.0.RELEASE.jar;D:\victor.min\mvn\org\slf4j\jcl-over-slf4j\1.7.21\jcl-over-slf4j-1.7.21.jar;D:\victor.min\mvn\org\slf4j\jul-to-slf4j\1.7.21\jul-to-slf4j-1.7.21.jar;D:\victor.min\mvn\org\slf4j\log4j-over-slf4j\1.7.21\log4j-over-slf4j-1.7.21.jar;D:\victor.min\mvn\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;D:\victor.min\mvn\org\springframework\boot\spring-boot-starter-tomcat\1.4.0.RELEASE\spring-boot-starter-tomcat-1.4.0.RELEASE.jar;D:\victor.min\mvn\org\apache\tomcat\embed\tomcat-embed-core\8.5.4\tomcat-embed-core-8.5.4.jar;D:\victor.min\mvn\org\apache\tomcat\embed\tomcat-embed-el\8.5.4\tomcat-embed-el-8.5.4.jar;D:\victor.min\mvn\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.4\tomcat-embed-websocket-8.5.4.jar;D:\victor.min\mvn\org\hibernate\hibernate-validator\5.2.4.Final\hibernate-validator-5.2.4.Final.jar;D:\victor.min\mvn\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;D:\victor.min\mvn\org\jboss\logging\jboss-logging\3.3.0.Final\jboss-logging-3.3.0.Final.jar;D:\victor.min\mvn\com\fasterxml\classmate\1.3.1\classmate-1.3.1.jar;D:\victor.min\mvn\com\fasterxml\jackson\core\jackson-databind\2.8.1\jackson-databind-2.8.1.jar;D:\victor.min\mvn\com\fasterxml\jackson\core\jackson-annotations\2.8.1\jackson-annotations-2.8.1.jar;D:\victor.min\mvn\com\fasterxml\jackson\core\jackson-core\2.8.1\jackson-core-2.8.1.jar;D:\victor.min\mvn\org\springframework\spring-web\4.3.2.RELEASE\spring-web-4.3.2.RELEASE.jar;D:\victor.min\mvn\org\springframework\boot\spring-boot-starter-actuator\1.4.0.RELEASE\spring-boot-starter-actuator-1.4.0.RELEASE.jar;D:\victor.min\mvn\org\springframework\boot\spring-boot-actuator\1.4.0.RELEASE\spring-boot-actuator-1.4.0.RELEASE.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.1\lib\idea_rt.jar" com.mzw.dragon.BootStrap
Connected to the target VM, address: '127.0.0.1:56369', transport: 'socket'
17:55:26.476 [main] INFO com.mzw.dragon.BootStrap - --------------------------------------------
17:55:26.479 [main] INFO com.mzw.dragon.BootStrap - ------------------application start--------------------------
17:55:27,268 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [file:/D:/victor.min/git/dragon-parent/dragon-assemble/target/classes/config/log/logback-spring.xml] 
17:55:27,268 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 2 minutes
17:55:27,271 |-INFO in ch.qos.logback.classic.joran.action.LoggerContextListenerAction - Adding LoggerContextListener of type [ch.qos.logback.classic.jul.LevelChangePropagator] to the object stack
17:55:27,278 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@16eccb2e - Propagating DEBUG level on Logger[ROOT] onto the JUL framework
17:55:27,278 |-INFO in ch.qos.logback.classic.joran.action.LoggerContextListenerAction - Starting LoggerContextListener
17:55:27,280 |-INFO in ch.qos.logback.classic.joran.action.ContextNameAction - Setting logger context name as [default]
17:55:27,281 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
17:55:27,281 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
17:55:27,282 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
17:55:27,304 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
17:55:27,306 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [INFO-APPENDER]
17:55:27,317 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@1388563249 - No compression will be used
17:55:27,318 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@1388563249 - Will use the pattern /var/log/webapps/dragon/apps.log.%d{yyyy-MM-dd}.%i for the active file
17:55:27,327 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@72437d8d - The date pattern is 'yyyy-MM-dd' from file name pattern '/var/log/webapps/dragon/apps.log.%d{yyyy-MM-dd}.%i'.
17:55:27,328 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@72437d8d - Roll-over at midnight.
17:55:27,331 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@72437d8d - Setting initial period to Thu Sep 22 17:47:14 CST 2016
17:55:27,344 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[INFO-APPENDER] - This appender no longer admits a layout as a sub-component, set an encoder instead.
17:55:27,344 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[INFO-APPENDER] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
17:55:27,344 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[INFO-APPENDER] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
17:55:27,345 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[INFO-APPENDER] - Active log file name: /var/log/webapps/dragon/apps.log
17:55:27,346 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[INFO-APPENDER] - File property is set to [/var/log/webapps/dragon/apps.log]
17:55:27,347 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
17:55:27,347 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [WARN-APPENDER]
17:55:27,349 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@2099051403 - No compression will be used
17:55:27,349 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@2099051403 - Will use the pattern /var/log/webapps/dragon/apps-warn-30dt.log.%d{yyyy-MM-dd}.%i for the active file
17:55:27,350 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@48e92c5c - The date pattern is 'yyyy-MM-dd' from file name pattern '/var/log/webapps/dragon/apps-warn-30dt.log.%d{yyyy-MM-dd}.%i'.
17:55:27,350 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@48e92c5c - Roll-over at midnight.
17:55:27,350 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@48e92c5c - Setting initial period to Thu Sep 22 17:47:14 CST 2016
17:55:27,351 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[WARN-APPENDER] - This appender no longer admits a layout as a sub-component, set an encoder instead.
17:55:27,351 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[WARN-APPENDER] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
17:55:27,351 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[WARN-APPENDER] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
17:55:27,353 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[WARN-APPENDER] - Active log file name: /var/log/webapps/dragon/apps-warn-30dt.log
17:55:27,353 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[WARN-APPENDER] - File property is set to [/var/log/webapps/dragon/apps-warn-30dt.log]
17:55:27,354 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
17:55:27,354 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [ERROR-APPENDER]
17:55:27,355 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@1265508963 - No compression will be used
17:55:27,355 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@1265508963 - Will use the pattern /var/log/webapps/dragon/apps-error-30dt.log.%d{yyyy-MM-dd}.%i for the active file
17:55:27,355 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@344f4dea - The date pattern is 'yyyy-MM-dd' from file name pattern '/var/log/webapps/dragon/apps-error-30dt.log.%d{yyyy-MM-dd}.%i'.
17:55:27,355 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@344f4dea - Roll-over at midnight.
17:55:27,356 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@344f4dea - Setting initial period to Thu Sep 22 17:47:14 CST 2016
17:55:27,357 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[ERROR-APPENDER] - This appender no longer admits a layout as a sub-component, set an encoder instead.
17:55:27,357 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[ERROR-APPENDER] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
17:55:27,357 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[ERROR-APPENDER] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
17:55:27,358 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ERROR-APPENDER] - Active log file name: /var/log/webapps/dragon/apps-error-30dt.log
17:55:27,358 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ERROR-APPENDER] - File property is set to [/var/log/webapps/dragon/apps-error-30dt.log]
17:55:27,358 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.apache] to true
17:55:27,358 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b7c473a - Propagating INFO level on Logger[org.apache] onto the JUL framework
17:55:27,358 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@16eccb2e - Propagating INFO level on Logger[org.apache] onto the JUL framework
17:55:27,358 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.apache level set to INFO
17:55:27,359 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.mzw.dragon] to true
17:55:27,359 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b7c473a - Propagating INFO level on Logger[org.mzw.dragon] onto the JUL framework
17:55:27,359 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@16eccb2e - Propagating INFO level on Logger[org.mzw.dragon] onto the JUL framework
17:55:27,359 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.mzw.dragon level set to INFO
17:55:27,359 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[org.mzw.dragon]
17:55:27,359 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.apache] to true
17:55:27,359 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - org.apache level set to INFO
17:55:27,359 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b7c473a - Propagating INFO level on Logger[ROOT] onto the JUL framework
17:55:27,359 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@16eccb2e - Propagating INFO level on Logger[ROOT] onto the JUL framework
17:55:27,359 |-INFO in ch.qos.logback.classic.joran.action.LevelAction - ROOT level set to INFO
17:55:27,359 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
17:55:27,359 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [INFO-APPENDER] to Logger[ROOT]
17:55:27,359 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [WARN-APPENDER] to Logger[ROOT]
17:55:27,359 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [ERROR-APPENDER] to Logger[ROOT]
17:55:27,359 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
17:55:27,359 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@2a62b5bc - Registering current configuration as safe fallback point

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.0.RELEASE)

2016-09-22 17:55:27.453 INFO  [           main] com.mzw.dragon.BootStrap:48 - Starting BootStrap on victor with PID 6976 (D:\victor.min\git\dragon-parent\dragon-assemble\target\classes started by Administrator in D:\victor.min\git\dragon-parent)
2016-09-22 17:55:27.455 INFO  [           main] com.mzw.dragon.BootStrap:663 - The following profiles are active: dev
2016-09-22 17:55:27.545 INFO  [           main] o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext:581 - Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@70f59913: startup date [Thu Sep 22 17:55:27 CST 2016]; root of context hierarchy
2016-09-22 17:55:27.749 INFO  [kground-preinit] o.h.validator.internal.util.Version:30 - HV000001: Hibernate Validator 5.2.4.Final
2016-09-22 17:55:28.707 INFO  [           main] o.s.b.f.xml.XmlBeanDefinitionReader:317 - Loading XML bean definitions from URL [file:/D:/victor.min/git/dragon-parent/dragon-assemble/target/classes/spring/spring-dragon-batch.xml]
2016-09-22 17:55:28.802 INFO  [           main] o.s.b.f.xml.XmlBeanDefinitionReader:317 - Loading XML bean definitions from URL [file:/D:/victor.min/git/dragon-parent/dragon-dal/target/classes/spring/spring-dbcp.xml]
2016-09-22 17:55:28.826 INFO  [           main] o.s.b.f.xml.XmlBeanDefinitionReader:317 - Loading XML bean definitions from URL [file:/D:/victor.min/git/dragon-parent/dragon-dal/target/classes/spring/spring-jpa-dev.xml]
2016-09-22 17:55:29.133 INFO  [           main] o.s.b.f.s.DefaultListableBeanFactory:843 - Overriding bean definition for bean 'org.springframework.transaction.config.internalTransactionAdvisor' with a different definition: replacing [Root bean: class [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration; factoryMethodName=transactionAdvisor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class]]
2016-09-22 17:55:29.134 INFO  [           main] o.s.c.a.ConfigurationClassBeanDefinitionReader:298 - Skipping bean definition for [BeanMethod:name=transactionalEventListenerFactory,declaringClass=org.springframework.transaction.annotation.AbstractTransactionManagementConfiguration]: a definition for bean 'org.springframework.transaction.config.internalTransactionalEventListenerFactory' already exists. This top-level bean definition is considered as an override.
2016-09-22 17:55:29.155 INFO  [           main] o.s.b.f.s.DefaultListableBeanFactory:843 - Overriding bean definition for bean 'characterEncodingFilter' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=dragonConfiguration; factoryMethodName=characterEncodingFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mzw/dragon/configuration/DragonConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration; factoryMethodName=characterEncodingFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/HttpEncodingAutoConfiguration.class]]
2016-09-22 17:55:29.418 INFO  [           main] o.s.c.s.PropertySourcesPlaceholderConfigurer:172 - Loading properties file from URL [file:/D:/victor.min/git/dragon-parent/dragon-dal/target/classes/config/db/dbcp-dev.properties]
2016-09-22 17:55:29.582 INFO  [           main] o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker:328 - Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$9db4bd9e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-09-22 17:55:30.132 INFO  [           main] com.mzw.dragon.BootStrap:34 - --------------------------------------------
2016-09-22 17:55:30.133 INFO  [           main] com.mzw.dragon.BootStrap:35 - ------------------customize start--------------------------
2016-09-22 17:55:30.133 INFO  [           main] com.mzw.dragon.BootStrap:37 - -------------------customize end-------------------------
2016-09-22 17:55:30.133 INFO  [           main] com.mzw.dragon.BootStrap:38 - --------------------------------------------
2016-09-22 17:55:30.357 INFO  [           main] o.s.b.c.e.t.TomcatEmbeddedServletContainer:88 - Tomcat initialized with port(s): 8088 (http)
2016-09-22 17:55:30.373 INFO  [           main] o.a.catalina.core.StandardService:179 - Starting service Tomcat
2016-09-22 17:55:30.374 INFO  [           main] o.a.catalina.core.StandardEngine:179 - Starting Servlet Engine: Apache Tomcat/8.5.4
2016-09-22 17:55:30.497 INFO  [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]:179 - Initializing Spring embedded WebApplicationContext
2016-09-22 17:55:30.497 INFO  [ost-startStop-1] o.s.web.context.ContextLoader:276 - Root WebApplicationContext: initialization completed in 2952 ms
2016-09-22 17:55:30.517 ERROR [ost-startStop-1] o.s.b.c.e.tomcat.TomcatStarter:63 - Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'dispatcherServlet' defined in class path resource [com/mzw/dragon/configuration/DragonConfiguration.class]: Unsatisfied dependency expressed through method 'dispatcherServlet' parameter 0: No qualifying bean of type [org.springframework.web.servlet.DispatcherServlet] found for dependency [org.springframework.web.servlet.DispatcherServlet]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.web.servlet.DispatcherServlet] found for dependency [org.springframework.web.servlet.DispatcherServlet]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
2016-09-22 17:55:30.549 WARN  [           main] o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext:549 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
2016-09-22 17:55:30.561 ERROR [           main] o.s.boot.SpringApplication:838 - Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
	at com.mzw.dragon.BootStrap.main(BootStrap.java:27)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:116)
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:83)
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:530)
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:176)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134)
	... 8 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dispatcherServlet' defined in class path resource [com/mzw/dragon/configuration/DragonConfiguration.class]: Unsatisfied dependency expressed through method 'dispatcherServlet' parameter 0: No qualifying bean of type [org.springframework.web.servlet.DispatcherServlet] found for dependency [org.springframework.web.servlet.DispatcherServlet]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.web.servlet.DispatcherServlet] found for dependency [org.springframework.web.servlet.DispatcherServlet]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:233)
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:214)
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:90)
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:78)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getServletContextInitializerBeans(EmbeddedWebApplicationContext.java:241)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:228)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:89)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:213)
	at org.springframework.boot.context.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:55)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.web.servlet.DispatcherServlet] found for dependency [org.springframework.web.servlet.DispatcherServlet]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1406)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1057)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1019)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
	... 26 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:56369', transport: 'socket'

Process finished with exit code 1



求大侠们看下呀 ~~~

加载中
0
wallacefw
wallacefw

我也遇到这个问题,求大神回答

_冢彧
_冢彧
在我上面的DragonConfiguration里面把 DispatcherServlet那个Bean去掉就行了,
0
J
Joemsu

建议多去看一下spring boot的文档吧, 你写的配置在application.yml里几句就搞定了,不需要这么麻烦

比如设置端口8088
server:
  port:8088
还有设置编码UTF-8, 其实spring boot默认设置的编码就是这个。完全不需要配置

 

0
love_forever
love_forever

楼主最后是怎么解决的?可否贴一下?

dissback
dissback
回复 @love_forever : 能否贴一下写的自定义bean代码样例谢谢 244090008@qq.com
love_forever
love_forever
回复 @_冢彧 : 嗯,后来用自定义的bean解决了,
_冢彧
_冢彧
其实感觉主要思想就是把以前在xml里面的配置全部用java代码来配置了,然后再加上注解。只是说有很多以前需要在xml里面配置的东西,Spring Boot会根据yml里的配置和引入的jar依赖加一些默认的配置
_冢彧
_冢彧
现在Spring Boot版本已经基本很稳定了,可以用1.5.10.REALEASE,CharactorEncodingFilter和那个DispatcherServlet Spring Boot会自动配置的,很多都有默认配置,如果需要自定义的话可以自己写Bean
返回顶部
顶部