春季启动配置问题

时间:2018-12-12 07:05:24

标签: java spring spring-boot

我是springboot的新手,我需要使用springboot部署项目。但是当我运行该应用程序时,会显示以下错误消息:

2018-12-12 14:22:17,714 [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.xml'
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadIntoGroup(ConfigFileApplicationListener.java:476)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:465)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:386)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:225)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:195)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    at com.pacer.track.server.bootstrap.Main.main(Main.java:9)
Caused by: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 77; Document root element "beans", must match DOCTYPE root "null".

我认为application.xml的bean出了点问题,并且还调查了相关问题,说同一项目中可能存在不同版本的spring,但是我发现application.xml和依赖项中没有错带来了。如果有人可以帮助我,我将不胜感激。

application.xml

<?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:dubbo="http://dubbo.apache.org/schema/dubbo" xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/rabbit
       http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd">

    <context:component-scan base-package="com.pacer.track.server"/>
    <aop:aspectj-autoproxy proxy-target-class="true"/>

    <dubbo:application name="track-server"/>
    <dubbo:registry address="N/A" check="false"/>
    <dubbo:protocol name="rest" port="${http.port}"/>

    <!-- redis config -->
    <import resource="redis-config.xml"/>

    <!-- rabbitmq config -->
    <import resource="rabbit-config.xml"/>

    <!-- database config -->
    <bean id="trackDataSource" class="com.zaxxer.hikari.HikariDataSource">
        <property name="driverClassName" value="org.postgresql.Driver"/>
        <property name="jdbcUrl" value="jdbc:postgresql://${postgres.host}:${postgres.port}/${postgres.dbname}"/>
        <property name="username" value="${postgres.username}"/>
        <property name="password" value="${postgres.password}"/>
    </bean>
    <bean id="trackSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="trackDataSource"/>
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
        <property name="mapperLocations">
            <list>
                <value>classpath:mapper/*.xml</value>
            </list>
        </property>
    </bean>
    <bean id="trackMapperConfigure" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.pacer.track.server.dao.mapper"/>
        <property name="sqlSessionFactoryBeanName" value="trackSqlSessionFactory"/>
    </bean>

    <!-- properties -->
    <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
        <property name="locations">
            <array>
                <value>classpath:api.properties</value>
                <value>classpath:application.properties</value>
            </array>
        </property>
    </bean>
</beans>

spring dependency

0 个答案:

没有答案