java.lang.IllegalStateException:无法加载ApplicationContext。无法使用spring boot创建war文件

时间:2018-06-18 04:55:32

标签: spring-boot

我的项目有spring boot作为客户端应用程序,Spring mvc项目作为服务层。这两个项目都在同一个包中,与嵌入式tomcat服务器配合良好。但现在我想将它部署在外部服务器上。为此,我需要创建war文件。

我更改了spring boot应用程序的pom.xml中的以下行。

 <packaging>war</packaging>
.
.
 <properties>   
   <start-class>com.nwn.Application</start-class>
 </properties>
.
.
  <build>
        <plugins>
            <!-- Package as an executable jar/war -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <addResources>true</addResources>
                    <profiles>
                        <profile>dev</profile>
                    </profiles>
                </configuration>
            </plugin>
        </plugins>
    </build>

我运行以下命令

 mvn package -Drun.profiles=dev

但最终会出现以下错误。

Description:

Field priceResultDAOMapper in com.nwn.price.service.PriceResultService required a bean of type 'com.nwn.price.dao.mybatis.pricing.mappers.PriceResultDAOMapper' that could not be found.


Action:

Consider defining a bean of type 'com.nwn.price.dao.mybatis.pricing.mappers.PriceResultDAOMapper' in your configuration.

2018-06-18 10:13:55.819 ERROR 9409 --- [           main] o.s.test.context.TestContextManager      : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@113e13f9] to prepare test instance [com.nwn.web.PriceFactorControllerTest@1bd8afc8]

java.lang.IllegalStateException: Failed to load ApplicationContext

另外,我的服务层项目包含一些预加载的方法。它使用mybatis来访问oracle数据库。

0 个答案:

没有答案