【发布时间】:2019-05-02 01:40:10
【问题描述】:
我在 Intellij 中运行 SpringBoot 应用程序时遇到问题。 @SpringBootApplication 位于子模块中
└── conf
└── xml
└──beans.xml
└── source
└── core
└── common
└── MainApplication.java --> @SpringBootApplication
└── config
└── pom.xml --> parent
MainApplication.java 有注解 @ImportResource("classpath:/beans.xml")
@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan(basePackages = {"com.xxx.yyy"})
@EnableCaching
@ImportResource("classpath:/beans.xml")
public class ServiceApplication extends SpringBootServletInitializer implements WebApplicationInitializer // extends SpringBootServletInitializer implements WebApplicationInitializer
{
“config”模块有 pom.xml,没有 java 文件。它只生成资源
<artifactId>config</artifactId>
<properties>
<environment>DEV</environment>
<country>ID</country>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<filters>
<filter>../../build/server.properties</filter>
</filters>
<resources>
<resource>
<directory>../../conf</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/**/log4j2.xml</exclude>
</excludes>
<targetPath>../../../../deploy/conf</targetPath>
</resource>
...
我尝试在 Intellij 上运行配置,但它为文件 beans.xml 产生错误 FileNotFoundException。此配置已在其他队友的 Eclipse 上运行。我想在 Intellij 上运行它。我已经在项目结构中导入了配置模块,并且 conf 文件夹已经标记为资源根。为什么它仍然不起作用?或者,如果我必须将更改附加到现有的 java 文件或 pom,没关系。只要应用程序可以找到到资源文件夹的方式。我不需要构建到战争中并运行它,但我只想作为 SpringBoot 应用程序运行
谢谢。任何帮助将不胜感激。
【问题讨论】:
标签: maven spring-boot intellij-idea