我的springboot应用程序在我添加了一个新的Jar到我的应用程序后停止工作。随着新的Jar的添加,我得到了下面的错误:
2023-04-20 12:51:26.755 WARN 4732 --- [ main] ConfigServletWebServerApplicationContext :
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'vehicleCapabilitiesExtractor' defined in file [C:\repo\Compare\kbc-core\kbc-core-app\target\classes\com\myApp\new\kbc\core\client\test\testCapabilitiesExtractor.class]:
Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'testtestService' defined in file [C:\repo\Compare\kbc-core\kbc-core-app\target\classes\com\myApp\new\kbc\core\test\testvehicle\TesttestService.class]:
Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'whiteListService' defined in file [C:\repo\Compare\kbc-core\kbc-core-database\target\classes\com\myApp\new\kbc\database\service\whitelist\WhiteListService.class]:
Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'whiteListRepository' defined in com.myApp.new.kbc.database.dao.whitelist.WhiteListRepository defined
in @EnableJpaRepositories declared on EntitiesAutoConfiguration: Invocation of init method failed; nested exception is
java.lang.IllegalArgumentException: Not a managed type: class com.myApp.new.kbc.database.dao.whitelist.WhiteListEntity
应用程序在一个单独的包中有数据库模块,并且运行良好。我的应用程序没有任何单独的db配置。但是,我添加的jar有以下配置:
@Configuration
@EntityScan({"com.kbc.newApp.${spring.application.id}"})
@EnableJpaRepositories({"com.kbc.newApp.${spring.application.id}"})
class EntitiesAutoConfiguration {
}
@ComponentScan(basePackages = "com.kbc.newApp.app.*")
@EnableAutoConfiguration
public class AslAppApplication {
@Bean
public EntityManagerFactoryBuilder entityManagerFactoryBuilder() {
return new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(), new HashMap<>(), null);
}
}
我尝试了在我的应用程序中添加@EntityScan,@EnableJpaRepositories @EntitiesAutoConfiguration的不同组合,但不知何故,我的实体无法识别。
1条答案
按热度按时间5hcedyr01#
添加
com.myApp.new.*
到EntityScan
和其他注解。@EntityScan(basePackages= {"com.myApp.new","com.kbc.newApp"})