当前位置: 首页 > 知识库问答 >
问题:

Spring Boot应用程序无法自动连接XML配置

齐振
2023-03-14

我正在尝试将现有的传统spring应用程序转换为Spring Boot程序。我已经用@ImportResource和运行应用程序时导入了XML配置。即使这个bean是在XML配置中配置的,它的抛出注入也失败了。我不知道这里出了什么问题

>Application.java

@Configuration
@ComponentScan("com.vzt")
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class })
public class Application {

public static void main(String[] args) {

    ApplicationContext applicationContext = SpringApplication.run(
            Application.class, args);

    System.out.println("Let's inspect the beans provided by Spring Boot:");

    String[] beanNames = applicationContext.getBeanDefinitionNames();
    Arrays.sort(beanNames);
    for (String beanName : beanNames) {
        System.out.println(beanName);
    }

}
}

@Configuration
@ImportResource("classpath:spring/beans.xml")
//    @Profile("itest2")  //commented it from the suggestion to set the     
spring.profiles.active=itest2 on VM arguments
class XMLImportingConfiguration {

} 
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"   xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:web-services="http://www.springframework.org/schema/web-services"
xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:util="http://www.springframework.org/schema/util"
xmlns:c="http://www.springframework.org/schema/c" xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/jee  http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.2.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
    http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">


<context:component-scan base-package="com.vzt" />

<!-- <oxm:jaxb2-marshaller id="marshaller" contextPath="com.vzt.ws.stubs.cca.ivrinfows" 
    /> -->


<!--    <jee:jndi-lookup id="ccaDataSource" jndi-name="java:/cca"
    resource-ref="true" />
 -->

<bean id="ccaDataSourceTest"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">

    <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
    <property name="url" value="${cca.jdbc.url}" />
    <property name="username" value="${cca.jdbc.username}" />
    <property name="password" value="${cca.jdbc.password}" />
</bean>


<bean id="ccaService" class="com.vzt.callcenter.service.CCAServiceImpl">
    <!-- wire dependency -->
</bean>

<bean id="ccaRepository" class="com.vzt.callcenter.dao.CCARepository">
    <property name="dataSource" ref="ccaDataSourceTest" />
</bean>

<bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    <property name="classesToBeBound">
        <list>
            <!-- IVR Info WS Request and Response Classes -->
            <value>com.vzt.ws.stubs.cca.ivrinfows.CallData</value>
            <value>com.vzt.ws.stubs.cca.ivrinfows.GetCallData</value>
            <value>com.vzt.ws.stubs.cca.ivrinfows.IvrTransfer</value>
            <value>com.vzt.ws.stubs.cca.ivrinfows.IvrTransferred</value>

            <!-- Weather Data WS Request and Response Classes -->
            <value>com.vzt.ws.stubs.weather.Alert</value>
            <value>com.vzt.ws.stubs.weather.DataSet</value>
            <value>com.vzt.ws.stubs.weather.GetAll</value>
            <value>com.vzt.ws.stubs.weather.GetAllResponse</value>
            <value>com.vzt.ws.stubs.weather.Weather</value>

            <!-- MW (ESB) Webservice SR Request and Response Classes -->
            <value>com.hughestelematics.htimessageheader.MessageHeaderT</value>
            <value>com.hughestelematics.xmlns.webservicesr.WebserviceSRRequest
            </value>
            <value>com.hughestelematics.xmlns.webservicesr.WebserviceSRReturn
            </value>

            <!-- Siebel Webservice updateSRType Request and Response Classes -->
            <value>com.siebel.customui.UpdateSRTypeInput</value>
            <value>com.siebel.customui.UpdateSRTypeOutput</value>

            <!-- MW (BPEL) Webservice SR PSTN Request and Response Classes -->
            <value>com.hti.xmlns.webservicepstn.ObjectFactory</value>
            <value>com.hti.xmlns.webservicepstn.PSTNRequestT</value>
            <value>com.hti.xmlns.webservicepstn.PSTNReturnT</value>
            <value>com.hti.xmlns.webservicepstn.PSTNOutput</value>


        </list>
    </property>
</bean>

<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">

    <property name="marshaller" ref="jaxb2Marshaller" />
    <property name="unmarshaller" ref="jaxb2Marshaller" />
    <constructor-arg ref="messageFactory" />


    <!-- <property name="defaultUri" value="${ccawebservice.url}" /> -->
    <property name="messageSender">
        <bean
            class="org.springframework.ws.transport.http.HttpComponentsMessageSender">
            <property name="connectionTimeout" value="${cca.ivrinfo.webservice.timeout}" />
            <property name="readTimeout" value="${cca.ivrinfo.webservice.timeout}" />
            <property name="acceptGzipEncoding" value="false" />
        </bean>
    </property>
</bean>

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
    <property name="messageFactory">
        <bean
            class="com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl" />
    </property>
</bean>


<!-- <mvc:default-servlet-handler /> -->

<mvc:resources location="/resources/" mapping="/resources/**" />

<!-- <mvc:interceptors> <bean class =  "com.vzt.nissan.interceptors.HttpRequestResponseLoggingInterceptor"/> 
    <bean class = "com.vzt.nissan.interceptors.AddSessionBeanInterceptor" /> 
    </mvc:interceptors> -->
<context:annotation-config />

<mvc:annotation-driven />
<aop:aspectj-autoproxy />

<beans profile="dev">
    <bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:framework_dev.properties</value>
                <value>classpath:data/testdata/testdata_dev.properties</value>
                <value>classpath:db/db_dev.properties</value>
            </list>
        </property>
    </bean>
</beans>


<beans profile="itest">
    <bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:framework_itest.properties</value>
                <value>classpath:data/testdata/testdata_itest.properties</value>
                <value>classpath:db/db_itest.properties</value>
            </list>
        </property>
    </bean>
</beans>

<beans profile="itest2">
    <bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:framework_itest2.properties</value>
                <value>classpath:data/testdata/testdata_itest2.properties</value>
                <value>classpath:db/db_itest2.properties</value>
            </list>
        </property>
    </bean>
</beans>
package com.vzt.callcenter.service;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.soap.client.SoapFaultClientException;
import com.vzt.callcenter.constants.Constants;  
import com.vzt.callcenter.model.GetCallDataByInteractionIdResponse;
import com.vzt.ws.stubs.cca.ivrinfows.CallData;
import com.vzt.ws.stubs.cca.ivrinfows.GetCallData;
import com.vzt.ws.stubs.cca.ivrinfows.IvrTransfer;
import com.vzt.ws.stubs.cca.ivrinfows.IvrTransferred;
import com.vzt.ws.stubs.cca.ivrinfows.ObjectFactory;

@Service
public class CCAServiceImpl implements CCAService {

@Autowired
private WebServiceTemplate webServiceTemplate;

static Logger logger = Logger.getLogger(CCAServiceImpl.class);

@Value("${cca.ivrinfo.webservice.url}")
private String webserviceUrl;

@Value("${cca.ivrinfo.webservice.timeout}")
private String webserviceTimeout;

public String getWebserviceUrl() {
    return webserviceUrl;
}

public void setWebserviceUrl(String webserviceUrl) {
    this.webserviceUrl = webserviceUrl;
}

public String getWebserviceTimeout() {
    return webserviceTimeout;
}

public void setWebserviceTimeout(String webserviceTimeout) {
    this.webserviceTimeout = webserviceTimeout;
}



/* (non-Javadoc)
 * @see com.vzt.callcenter.service.CCAService#getCallDataByInteractionId(java.lang.String)
 */
@Override
public GetCallDataByInteractionIdResponse getCallDataByInteractionId(
        String interactionId) {

      //code not shown for brevity
    return getCallDataByInteractionIdResponse;
}

/* (non-Javadoc)
 * @see com.vzt.callcenter.service.CCAService#ivrTransfer(com.vzt.callcenter.model.IvrTransferRequest)
 */
@Override
public String ivrTransfer(com.vzt.callcenter.model.IvrTransferRequest ivrTransferRequest) {

    logger.info("Request:" + ivrTransferRequest);

      //code not shown for brevity

    return Constants.WS_RC_CCAINFOWS_WSEXCEPTION;
}
}
Based on USER:axtavt comment, I made change to the
spring.active.profiles on run-time instead of using @Annotations.  And
now I get the below error.

org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4260904e: startup date [Thu Dec 11 09:47:19 EST 2014]; root of context hierarchy
09:47:19 DEBUG ntext.embedded.AnnotationConfigEmbeddedWebApplicationContext obtainFreshBeanFactory    Bean factory for org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4260904e: org.springframework.beans.factory.support.DefaultListableBeanFactory@4db8738f: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,application]; root of factory hierarchy
09:47:20 INFO  rg.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions       Loading XML bean definitions from class path resource [spring/beans.xml]
09:47:21 INFO  ngframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition    Overriding bean definition for bean 'mvcContentNegotiationManager': replacing [Root bean: class [org.springframework.web.accept.ContentNegotiationManagerFactoryBean]; 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.web.servlet.config.annotation.DelegatingWebMvcConfiguration; factoryMethodName=mvcContentNegotiationManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]]
09:47:21 INFO  rk.context.annotation.ConfigurationClassBeanDefinitionReader iddenByExistingDefinition Skipping bean definition for [BeanMethod:name=mvcUriComponentsContributor,declaringClass=org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport]: a definition for bean 'mvcUriComponentsContributor' already exists. This top-level bean definition is considered as an override.
09:47:21 INFO  ngframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition    Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.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.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
09:47:21 INFO  framework.beans.factory.config.PropertyPlaceholderConfigurer loadProperties            Loading properties file from class path resource [framework_itest2.properties]
09:47:21 INFO  framework.beans.factory.config.PropertyPlaceholderConfigurer loadProperties            Loading properties file from class path resource [data/testdata/testdata_itest2.properties]
09:47:21 INFO  framework.beans.factory.config.PropertyPlaceholderConfigurer loadProperties            Loading properties file from class path resource [db/db_itest2.properties]
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
09:47:22 INFO  t.PostProcessorRegistrationDelegate$BeanPostProcessorChecker rocessAfterInitialization Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$acc877c3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
09:47:22 INFO  t.PostProcessorRegistrationDelegate$BeanPostProcessorChecker rocessAfterInitialization Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
09:47:22 INFO  t.PostProcessorRegistrationDelegate$BeanPostProcessorChecker rocessAfterInitialization Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
09:47:22 INFO  t.PostProcessorRegistrationDelegate$BeanPostProcessorChecker rocessAfterInitialization Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
09:47:22 DEBUG ntext.embedded.AnnotationConfigEmbeddedWebApplicationContext initMessageSource         Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@773fe60f]
09:47:22 DEBUG ntext.embedded.AnnotationConfigEmbeddedWebApplicationContext plicationEventMulticaster Using ApplicationEventMulticaster [org.springframework.context.event.SimpleApplicationEventMulticaster@4191ff3]
09:47:22 DEBUG ontext.embedded.tomcat.TomcatEmbeddedServletContainerFactory etArchiveFileDocumentRoot Code archive: C:\Users\v579424\.m2\repository\org\springframework\boot\spring-boot\1.1.7.RELEASE\spring-boot-1.1.7.RELEASE.jar
09:47:22 DEBUG ontext.embedded.tomcat.TomcatEmbeddedServletContainerFactory plodedWarFileDocumentRoot Code archive: C:\Users\v579424\.m2\repository\org\springframework\boot\spring-boot\1.1.7.RELEASE\spring-boot-1.1.7.RELEASE.jar
09:47:22 DEBUG ontext.embedded.tomcat.TomcatEmbeddedServletContainerFactory getValidDocumentRoot      Document root: C:\Users\v579424\Documents\workspace-sts-3.4.0.RELEASE\VZTCallCenterFramework\src\main\webapp
09:47:22 INFO  ontext.embedded.tomcat.TomcatEmbeddedServletContainerFactory tEmbeddedServletContainer Server initialized with port: 8080
09:47:22 INFO                 org.springframework.web.context.ContextLoader ddedWebApplicationContext Root WebApplicationContext: initialization completed in 3087 ms
09:47:23 INFO  pringframework.boot.context.embedded.ServletRegistrationBean onStartup                 Mapping servlet: 'dispatcherServlet' to [/]
09:47:23 INFO  springframework.boot.context.embedded.FilterRegistrationBean configure                 Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
09:47:26 INFO                  org.springframework.oxm.jaxb.Jaxb2Marshaller ateJaxbContextFromClasses Creating JAXBContext with classes to be bound [class com.vzt.ws.stubs.cca.ivrinfows.CallData,class com.vzt.ws.stubs.cca.ivrinfows.GetCallData,class com.vzt.ws.stubs.cca.ivrinfows.IvrTransfer,class com.vzt.ws.stubs.cca.ivrinfows.IvrTransferred,class com.vzt.ws.stubs.weather.Alert,class com.vzt.ws.stubs.weather.DataSet,class com.vzt.ws.stubs.weather.GetAll,class com.vzt.ws.stubs.weather.GetAllResponse,class com.vzt.ws.stubs.weather.Weather,class com.hughestelematics.htimessageheader.MessageHeaderT,class com.hughestelematics.xmlns.webservicesr.WebserviceSRRequest,class com.hughestelematics.xmlns.webservicesr.WebserviceSRReturn,class com.siebel.customui.UpdateSRTypeInput,class com.siebel.customui.UpdateSRTypeOutput,class com.hti.xmlns.webservicepstn.ObjectFactory,class com.hti.xmlns.webservicepstn.PSTNRequestT,class com.hti.xmlns.webservicepstn.PSTNReturnT,class com.hti.xmlns.webservicepstn.PSTNOutput]
09:47:27 INFO   org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName        Loaded JDBC driver: oracle.jdbc.OracleDriver
09:47:27 INFO  .springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler           Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
09:47:27 INFO  b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod     Mapped "{[/service/customAgentRoute/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List<com.vzt.callcenter.model.CustomRoute> com.vzt.callcenter.web.CustomAgentRouteController.customAgentRoutes()
09:47:27 INFO  b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod     Mapped "{[/service/customAgentRoute/{mdn}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.vzt.callcenter.model.CustomRoute com.vzt.callcenter.web.CustomAgentRouteController.getCustomRougeByMdn(java.lang.String)
09:47:27 INFO  b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod     Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
09:47:27 INFO  b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod     Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
09:47:28 INFO  .springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler           Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
09:47:28 INFO  b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod     Mapped "{[/service/customAgentRoute/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List<com.vzt.callcenter.model.CustomRoute> com.vzt.callcenter.web.CustomAgentRouteController.customAgentRoutes()
09:47:28 INFO  b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod     Mapped "{[/service/customAgentRoute/{mdn}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.vzt.callcenter.model.CustomRoute com.vzt.callcenter.web.CustomAgentRouteController.getCustomRougeByMdn(java.lang.String)
09:47:28 INFO  b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod     Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
09:47:28 INFO  b.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod     Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
09:47:28 INFO  .springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler           Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
09:47:28 INFO  .springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler           Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
09:47:28 INFO  pringframework.jmx.export.annotation.AnnotationMBeanExporter afterPropertiesSet        Registering beans for JMX exposure on startup
09:47:28 DEBUG ntext.embedded.AnnotationConfigEmbeddedWebApplicationContext initLifecycleProcessor    Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor@27b6c151]
09:47:28 DEBUG oconfigure.logging.AutoConfigurationReportLoggingInitializer ogAutoConfigurationReport 



    09:47:28 ERROR                   org.springframework.boot.SpringApplication run                       Application startup failed
    java.lang.IllegalStateException: Tomcat connector in failed state
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:154)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:272)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:132)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:485)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
        at com.vzt.Application.main(Application.java:28)
    09:47:28 INFO  ntext.embedded.AnnotationConfigEmbeddedWebApplicationContext doClose                   Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4260904e: startup date [Thu Dec 11 09:47:19 EST 2014]; root of context hierarchy
    09:47:28 INFO  pringframework.jmx.export.annotation.AnnotationMBeanExporter destroy                   Unregistering JMX-exposed beans on shutdown
    Exception in thread "main" java.lang.IllegalStateException: Tomcat connector in failed state
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:154)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:272)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:132)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:485)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
        at com.vzt.Application.main(Application.java:28)
    **

共有1个答案

丁英韶
2023-03-14

通过在VM参数上传递spring.profiles.active=itest2而不是将其设置为如下所示的注释来修复它。不确定,为什么spring-boot不允许使用注释进行配置。

@Configuration
@ImportResource("classpath:spring/beans.xml")
@Profile("itest2")    
class XMLImportingConfiguration {

} 
 类似资料:
  • 我有一个应用类 我有控制器课 并且,我想为Application test编写一个测试用例,以确保创建的实例类型为HelloController 但是,我在自动连接 hello控制器变量时遇到错误(找不到 hello 控制器类型的 bean)。根据我的理解,@SpringBootTest应该创建上下文并返回一个实例。我们不需要编写任何上下文 xml 或使用任何注释Config 类来获取实例。缺少了

  • 尝试使用主连接字符串和用户名(数据库名)连接到cosmosdb Mongo API 原因:com.mongodb.mongotieoutexception:在等待与com.mongodb.client.internal.mongoclientdelegate$1@3C291AAD匹配的服务器时,在30000 ms后超时。群集状态的客户端视图是{type=replica_set,servers=[{

  • 我创建了一个SpringBoot的示例项目,以了解外部客户机功能,运行时会出现以下错误。 com.example.demo.RestClient中的字段Remote teCallClient需要一个类型为com.example.demo.Remote teCallClient的bean,但找不到。操作:考虑在配置中定义类型为com.example.demo.远程呼叫客户端的bean。 我尝试了各种

  • 我的程序编译了所有内容,我没有出错,但我实际上期望tomcat应该永久在端口8080上。输出中也没有Spring。在另一个项目中,我做的一切都很好。谢谢你帮助我。 我的父母: 我的tarter.class: 我的Starter-Pom: 控制台输出: 然后什么都不会发生了。谢谢你的帮助。

  • 我生成了一个。我的SpringMVC Maven Hibernate MySQL应用程序的war文件,该应用程序在本地主机和本地MySQL数据库上运行良好。我配置数据库的方式是通过WebAppConfig。查看应用程序的java文件。属性文件并检索适当的信息。 然后我创建了一个OpenShift帐户并部署了它。war文件。我添加了MySQL和PHPMyAdmin盒带,以便维护数据库。当我试图通过我