Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.>
<Jun 14, 2021 11:07:01 AM EEST> <Notice> <Stdout> <BEA-000000> <2021-06-14 11:07:01.740 ERROR 7845 --- [ (self-tuning)'] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method entityManagerFactory in demo.Db1Config required a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' in your configuration.>
<Jun 14, 2021 11:07:01 AM EEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "430590093957351" for task "888" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}"
weblogic.application.ModuleException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:237)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:232)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1777)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1333)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
Truncated. see log file for complete stacktrace
@Configuration
@EnableTransactionManagement
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
@EnableJpaRepositories(entityManagerFactoryRef = "db1EntityManagerFactory",
basePackages = {"demo.db1.repo"})
public class Db1Config {
@Primary
@Bean(name = "db1DataSource", destroyMethod="")
@ConfigurationProperties(prefix = "db1.datasource")
public DataSource dataSource() {
JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
DataSource dataSource = dataSourceLookup.getDataSource("jdbc/JNDI_NAME_1");
return dataSource;
}
@Primary
@Bean(name = "db1EntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
EntityManagerFactoryBuilder builder, @Qualifier("db1DataSource") DataSource dataSource) {
return builder.dataSource(dataSource).packages("demo.db1.domain").persistenceUnit("db1")
.build();
}
@Primary
@Bean(name = "db1TransactionManager")
public PlatformTransactionManager transactionManager(
@Qualifier("db1EntityManagerFactory") EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
}
@Configuration
@EnableTransactionManagement
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
@EnableJpaRepositories(entityManagerFactoryRef = "db2EntityManagerFactory",
transactionManagerRef = "db2TransactionManager", basePackages = {"demo.db2.repo"})
public class Db2Config {
@Bean(name = "db2DataSource", destroyMethod="")
@ConfigurationProperties(prefix = "db2.datasource")
public DataSource dataSource() {
JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
DataSource dataSource = dataSourceLookup.getDataSource("jdbc/JNDI_NAME_2");
return dataSource;
}
@Bean(name = "db2EntityManagerFactory")
public LocalContainerEntityManagerFactoryBean barEntityManagerFactory(
EntityManagerFactoryBuilder builder, @Qualifier("db2DataSource") DataSource dataSource) {
return builder.dataSource(dataSource).packages("demo.db2.domain").persistenceUnit("db2")
.build();
}
@Bean(name = "db2TransactionManager")
public PlatformTransactionManager barTransactionManager(
@Qualifier("db2EntityManagerFactory") EntityManagerFactory barEntityManagerFactory) {
return new JpaTransactionManager(barEntityManagerFactory);
}
}
application.java:
@SpringBootApplication(exclude = HibernateJpaAutoConfiguration.class)
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
servletInitializer.java:
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setMaxFileSize(DataSize.ofMegabytes(100000L));
factory.setMaxRequestSize(DataSize.ofMegabytes(100000L));
return factory.createMultipartConfig();
}
}
您已经切换了Datasource的自动配置,因此EntityManagerFactoryBuilder
不是从spring本身配置和处理的。
试着改变
@enableAutoConfiguration(exclude={datasourceAutoConfiguration.class})
使用mvn spring boot启动时:run或甚至使用gradle返回该问题。 这里是主要的类,在我看来所有的需求都可以,我使用的是org.springframework.boot版本1.5.7 以及: 使用Maven或Gradle会返回相同的问题。所有注释和包名称似乎都符合要求。
我一直在学习如何使用spring数据,并创建了一个非常简单的项目来测试它。文件夹结构和applicationcontext。xml显示在这里:applicationcontext。xml和文件夹结构我得到的错误显示在这里:控制台错误输出。我在类路径上有applicationContext,并声明了该类的bean,你知道我的问题是什么吗?非常感谢。 编辑:我已经更新了我的帖子,以显示主类和道类,以及
我只是试图通过本教程springboot,但当我运行它显示一个错误。我不明白这个错误。 ”描述: com.mii.tugas.中setEmf方法的参数0。Mahasiswao需要一个无法找到的'javax.persistence.EntityManagerFactory'类型的bean。 措施: 考虑定义“javax”类型的bean。坚持不懈配置中的EntityManagerFactory。" 这
由于某种原因,这段代码给出了编译错误,有人能解释为什么吗?
问题内容: 码: 忽略字符串中的其他内容(最小,最大和范围),但对于此行, 我收到一个错误: 必需:double [] 找到:无参数 为什么会出现此错误,我应该更改什么? 问题答案: 您以这种方式调用方法calculateAverage :,不带任何参数。但是方法是这样声明的: 因此,它需要一个type类型的参数,但是您什么也不传递。