【发布时间】:2017-04-15 17:11:07
【问题描述】:
在我的 Spring Boot 1.5.2 应用程序中,出现以下异常:
java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
我读到如果没有标有@Entity 的类,这是Spring Boot 1.4.1 中的一个错误,但是,我使用的是较新版本,并且我也有用@Entity 注释的类,所以我真的不知道'不知道错误的原因可能是什么。
我的SpringApplication 类位于org.common.deployment 和org.common.deployment.model 中的实体,所以如果我这样注释我的SpringApplication 类,应该可以找到实体:
@SpringBootApplication
@EnableTransactionManagement
public class DeploymentBootstrapper {
public static void main(String[] args) {
SpringApplication.run(DeploymentBootstrapper.class, args);
}
...
}
该错误仅在我在 GitLab CI 服务器上构建项目时发生,而不是在我在本地运行单元测试时发生。
【问题讨论】:
-
您不需要使用
@EnableTransactionManagement注释应用程序。它将基于类路径资源启用。尝试删除它。 spring.io/guides/gs/managing-transactions
标签: java jpa spring-boot