2016-04-07 13 views
1

Spring Boot klasik bir yay çerçeve uygulaması dönüştürdük taşıma varsayılan sunucu uygulamasını yapılandırmak için gerekli ve şimdi bu oluyor:Bahar önyükleme: Bir ServletContext'te

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

2016-04-07 08:32:47.588 INFO 2448 --- [   main] b.c.j.besser.core.BesserCoreApplication : Starting BesserCoreApplication on roberton with PID 2448 (D:\JJW\srcBesser\besser-core\target\classes started by Roberto in D:\JJW\srcBesser\besser-core) 
2016-04-07 08:32:47.599 INFO 2448 --- [   main] b.c.j.besser.core.BesserCoreApplication : No active profile set, falling back to default profiles: default 
2016-04-07 08:32:48.059 INFO 2448 --- [   main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]47d9a273: startup date [Thu Apr 07 08:32:48 BRT 2016]; root of context hierarchy 
2016-04-07 08:32:51.815 INFO 2448 --- [   main] o.s.s.a.AsyncAnnotationBeanPostProcessor : No TaskExecutor bean found for async annotation processing. 
2016-04-07 08:32:52.114 INFO 2448 --- [   main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [class org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$c59662e5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2016-04-07 08:32:52.506 INFO 2448 --- [   main] trationDelegate$BeanPostProcessorChecker : Bean 'objectPostProcessor' of type [class org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2016-04-07 08:32:52.517 INFO 2448 --- [   main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.[email protected]2bbb44da' of type [class org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2016-04-07 08:32:52.543 INFO 2448 --- [   main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [class org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$78749757] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2016-04-07 08:32:52.604 INFO 2448 --- [   main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [class org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2016-04-07 08:32:52.644 INFO 2448 --- [   main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$9c7519eb] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2016-04-07 08:32:52.760 INFO 2448 --- [   main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cache.annotation.ProxyCachingConfiguration' of type [class org.springframework.cache.annotation.ProxyCachingConfiguration$$EnhancerBySpringCGLIB$$3d2e449] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2016-04-07 08:32:54.537 INFO 2448 --- [   main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 
2016-04-07 08:32:54.564 INFO 2448 --- [   main] o.apache.catalina.core.StandardService : Starting service Tomcat 
2016-04-07 08:32:54.566 INFO 2448 --- [   main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.32 
2016-04-07 08:32:55.770 INFO 2448 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner  : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 
2016-04-07 08:32:55.778 INFO 2448 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]  : Initializing Spring embedded WebApplicationContext 
2016-04-07 08:32:55.779 INFO 2448 --- [ost-startStop-1] o.s.web.context.ContextLoader   : Root WebApplicationContext: initialization completed in 7727 ms 
2016-04-07 08:32:57.002 INFO 2448 --- [g-Init-Reporter] com.mchange.v2.log.MLog     : MLog clients using slf4j logging. 
2016-04-07 08:32:57.093 INFO 2448 --- [ost-startStop-1] com.mchange.v2.c3p0.C3P0Registry   : Initializing c3p0-0.9.5.1 [built 16-June-2015 00:06:36 -0700; debug? true; trace: 10] 
2016-04-07 08:32:57.926 INFO 2448 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'pu' 
2016-04-07 08:32:57.957 INFO 2448 --- [ost-startStop-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ 
    name: pu 
    ...] 
2016-04-07 08:32:58.158 INFO 2448 --- [ost-startStop-1] org.hibernate.Version     : HHH000412: Hibernate Core {4.3.11.Final} 
2016-04-07 08:32:58.163 INFO 2448 --- [ost-startStop-1] org.hibernate.cfg.Environment   : HHH000206: hibernate.properties not found 
2016-04-07 08:32:58.167 INFO 2448 --- [ost-startStop-1] org.hibernate.cfg.Environment   : HHH000021: Bytecode provider name : javassist 
2016-04-07 08:32:58.750 INFO 2448 --- [ost-startStop-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final} 
2016-04-07 08:32:59.079 INFO 2448 --- [ost-startStop-1] c.m.v.c.i.AbstractPoolBackedDataSource : Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 30000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 1b61c019f1uq94rx1amrowc|b5a3aa3, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.firebirdsql.jdbc.FBDriver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 1b61c019f1uq94rx1amrowc|b5a3aa3, idleConnectionTestPeriod -> 300, initialPoolSize -> 2, jdbcUrl -> jdbc:firebirdsql:192.168.15.250:/datasource/patomuxi/mercotoys.fdb?encoding=ISO8859_1, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 900, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 10, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> select first 1 1 from RDB$DATABASE, privilegeSpawnedThreads -> false, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ] 
2016-04-07 08:32:59.115 WARN 2448 --- [ost-startStop-1] c.m.v2.resourcepool.BasicResourcePool : Bad pool size config, start 2 < min 3. Using 3 as start. 
2016-04-07 08:32:59.854 INFO 2448 --- [ost-startStop-1] org.hibernate.dialect.Dialect   : HHH000400: Using dialect: org.hibernate.dialect.FirebirdDialect 
2016-04-07 08:33:00.992 INFO 2448 --- [ost-startStop-1] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory 
2016-04-07 08:33:16.722 INFO 2448 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 
2016-04-07 08:33:16.725 INFO 2448 --- [ost-startStop-1] .e.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 
2016-04-07 08:33:16.725 INFO 2448 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'tokenAuthenticationFilter' to: [/*] 
2016-04-07 08:33:16.725 INFO 2448 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/] 
2016-04-07 08:33:17.409 INFO 2448 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain  : Creating filter chain: [email protected]1, [org.springframework.secu[email protected]4fd33ae3, org.spring[email protected]7835caf0, [email protected]253, org.springframework.secu[email protected], [email protected]63293d93, org.springfram[email protected]737d8efb, org.sp[email protected]1b678950, org.springframework.[email protected]43f05caf, org.springfram[email protected]2afe0b48, o[email protected]82e98a2, org[email protected]2c14c825, org.springfr[email protected]3c2b82e3] 
2016-04-07 08:33:25.841 WARN 2448 --- [   main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [br/com/jjw/besser/core/configuration/MvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling 
2016-04-07 08:33:25.869 INFO 2448 --- [   main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'pu' 
2016-04-07 08:33:25.879 INFO 2448 --- [   main] o.apache.catalina.core.StandardService : Stopping service Tomcat 
2016-04-07 08:33:25.897 ERROR 2448 --- [   main] o.s.boot.SpringApplication    : Application startup failed 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [br/com/jjw/besser/core/configuration/MvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling 
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] 
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] 
    at br.com.jjw.besser.core.BesserCoreApplication.main(BesserCoreApplication.java:15) [classes/:na] 
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    ... 18 common frames omitted 
Caused by: java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling 
    at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer.<init>(DefaultServletHandlerConfigurer.java:53) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping(WebMvcConfigurationSupport.java:451) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at br.com.jjw.besser.core.configuration.MvcConfiguration$$EnhancerBySpringCGLIB$$cb14c397.CGLIB$defaultServletHandlerMapping$23(<generated>) ~[classes/:na] 
    at br.com.jjw.besser.core.configuration.MvcConfiguration$$EnhancerBySpringCGLIB$$cb14c397$$FastClassBySpringCGLIB$$1f6cf842.invoke(<generated>) ~[classes/:na] 
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:355) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at br.com.jjw.besser.core.configuration.MvcConfiguration$$EnhancerBySpringCGLIB$$cb14c397.defaultServletHandlerMapping(<generated>) ~[classes/:na] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45] 
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45] 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    ... 19 common frames omitted 

Bu, neden köküdür messageSource fasulye:

@Configuration 
public class MvcConfiguration extends WebMvcConfigurationSupport { 

    @Bean(name = "messageSource") 
    public MessageSource messageSource() { 
     ReloadableResourceBundleMessageSource messages = new ReloadableResourceBundleMessageSource(); 
     messages.setBasenames("classpath:beanValidation", "classpath:errors"); 
     messages.setDefaultEncoding("UTF-8"); 
     return messages; 
    } 

    @Override 
    protected Validator getValidator() { 
     LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean(); 
     validator.setValidationMessageSource(messageSource()); 
     return validator; 
    } 
} 

ben adlandırmak messageSource yöntem messageSource2için çalıştığını, ama ben n değilim Özel mesajlar için sorgulamak üzere LocalizedMessageService benim MessageSource otomatik olarak kullanmak için abble kullanabilirsiniz.

Varsayılan MessageSource'a özel mesaj temel adlarını nasıl ekleyebilirim?

+0

Herhangi bir servlet eşlemesi veya @ Servlet, @ Yapılandırma ek açıklaması eklediniz mi? aynı zamanda şu adresten de bakabilirsiniz: br.com.jjw.besser.core.BesserCoreApplication.main (BesserCoreApplication.java:15) ' –

+0

Bu https://spring.io/guides/gs adresine de bakmak isteyebilirsiniz./spring-boot/.. kodunuzu paylaşmadığınız için eksik olduğunuzu değerlendirmek zordur. –

+1

Yardım almak için en azından uygulamanızı önyükleme yapan yapılandırma dosyalarınızı paylaşın. – dumitru

cevap

6

Çözüldü.

Ben MvcConfiguration den messageSource fasulye ayrılmış, ben başka yapılandırma sınıfının içine koydu:

@Configuration 
public class LocalizationConfiguration { 

    @Bean 
    public MessageSource messageSource() { 
     ReloadableResourceBundleMessageSource messages = new ReloadableResourceBundleMessageSource(); 
     messages.setBasenames("classpath:beanValidation", "classpath:errors"); 
     messages.setDefaultEncoding("UTF-8"); 
     return messages; 
    } 

} 

Aparently, benim WebMvcConfigurationSupport uzatma messageSource başlatamazsınız.

+0

Merhaba, bir çözümü paylaştığınız için teşekkürler. Şimdi 'getValidator()' yönteminde nasıl kullanıyorsunuz? MvcConfiguration sınıfınızda "LocalizationConfiguration" türünde bir alanınız var mı? – kiedysktos

+0

Bir Validator tanımlamamışım, validador'u başlatmak için Spring Boot otomatik yapılandırıcıyı kullanıyorum. Sınıf yolunuzda "hazırda bekletme-validator" olmanız yeterlidir ve yay, "messageSource" fasulyesini yerelleştirmenin kaynağı olarak kullanmakla ilgilenir. –

İlgili konular