我第一次用这个例子试用这个启动器:rdbms
但我得到了以下例外:Cannot invoke "org.teiid.spring.common.ExternalSource.getTranslatorName()" because "es" is null
2021-06-22 01:29:57.683 WARN 1204195 --- [ main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'db' defined in class path resource [com/test/application/DataSources.class]: Initialization of bean failed; nested exception is java.lang.NullPointerException: Cannot invoke "org.teiid.spring.common.ExternalSource.getTranslatorName()" because "es" is null
我不确定它出了什么问题,因为你可以看到它找到了数据源,但仍然抛出异常,我是不是遗漏了什么?
2021-06-22 01:36:47.253 INFO 1205224 --- [ main] o.t.s.a.TeiidBeanDefinitionPostProcessor : Found data sources: [db]
项目配置:
# JPA
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.generate-ddl=false
# DATA SOURCES
spring.datasource.db.jdbc-url=jdbc:postgresql://localhost:15432/db
spring.datasource.db.username=postgres
spring.datasource.db.password=password
spring.datasource.db.driver-class-name=org.postgresql.Driver
spring.datasource.db.platform=db
spring.datasource.db.pool-size=10
#spring.datasource.db.maximumPoolSize=5
spring.datasource.db.minimumIdle=0
# TEIID
spring.datasource.db.importer.SchemaPattern=public
spring.teiid.model.package=com.test
#spring.teiid.file.parent-directory=src/main/resources
#teiid.jdbc-enable=true
#teiid.jdbc-port=15432
#teiid.pg-enable=true
#teiid.pg-port=15432
logging.level.org.teiid.spring=DEBUG
我的DataSourceConfiguration文件:
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false)
public class DataSources {
@ConfigurationProperties(prefix = "spring.datasource.db")
@Bean
public HikariDataSource db() {
return DataSourceBuilder.create().type(HikariDataSource.class).build();
}
//.. REST OF THE SOURCES DOWN BELOW
}
我的POM.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- DATA JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- POSTGRES -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<!-- TEIID -->
<dependency>
<groupId>org.teiid</groupId>
<artifactId>teiid-spring-boot-starter</artifactId>
<version>1.7.1</version>
</dependency>
这是完整的日志
2021-06-22 01:36:46.168 INFO 1205224 --- [ main] c.v.s.Application : Starting Application using Java 15.0.3 on test with PID 1205224 (/.../target/classes started by test in /.../)
2021-06-22 01:36:46.172 INFO 1205224 --- [ main] c.v.s.Application : The following profiles are active: dev
2021-06-22 01:36:47.124 INFO 1205224 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-06-22 01:36:47.183 INFO 1205224 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 51 ms. Found 1 JPA repository interfaces.
2021-06-22 01:36:47.253 INFO 1205224 --- [ main] o.t.s.a.TeiidBeanDefinitionPostProcessor : Found data sources: [db]
2021-06-22 01:36:47.372 INFO 1205224 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.teiid.spring.autoconfigure.TransactionManagerConfiguration' of type [org.teiid.spring.autoconfigure.TransactionManagerConfiguration$$EnhancerBySpringCGLIB$$e85c9080] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-06-22 01:36:47.381 INFO 1205224 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'platformTransactionManagerAdapter' of type [org.teiid.spring.autoconfigure.PlatformTransactionManagerAdapter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-06-22 01:36:47.591 INFO 1205224 --- [ main] o.t.s.a.TeiidAutoConfiguration : Starting Teiid Server.
2021-06-22 01:36:48.240 INFO 1205224 --- [ main] org.teiid.RUNTIME.VDBLifeCycleListener : TEIID40118 VDB spring.1.0.0 added to the repository
2021-06-22 01:36:48.243 INFO 1205224 --- [ main] org.teiid.RUNTIME.VDBLifeCycleListener : TEIID40003 VDB spring.1.0.0 is set to ACTIVE
2021-06-22 01:36:48.259 WARN 1205224 --- [ main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'db' defined in class path resource [com/test/sourcereader/application/DataSources.class]: Initialization of bean failed; nested exception is java.lang.NullPointerException: Cannot invoke "org.teiid.spring.common.ExternalSource.getTranslatorName()" because "es" is null
2021-06-22 01:36:48.284 INFO 1205224 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-06-22 01:36:48.307 ERROR 1205224 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'db' defined in class path resource [com/test/application/DataSources.class]: Initialization of bean failed; nested exception is java.lang.NullPointerException: Cannot invoke "org.teiid.spring.common.ExternalSource.getTranslatorName()" because "es" is null
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1334) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.8.jar:5.3.8]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.8.jar:5.3.8]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.8.jar:5.3.8]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:64) ~[spring-boot-2.5.1.jar:2.5.1]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.1.jar:2.5.1]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.1.jar:2.5.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.1.jar:2.5.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.1.jar:2.5.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.1.jar:2.5.1]
at com.test.Application.main(Application.java:12) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'db' defined in class path resource [com/test/application/DataSources.class]: Initialization of bean failed; nested exception is java.lang.NullPointerException: Cannot invoke "org.teiid.spring.common.ExternalSource.getTranslatorName()" because "es" is null
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:610) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.8.jar:5.3.8]
... 21 common frames omitted
Caused by: java.lang.NullPointerException: Cannot invoke "org.teiid.spring.common.ExternalSource.getTranslatorName()" because "es" is null
at org.teiid.spring.autoconfigure.TeiidServer.buildModelFromDataSource(TeiidServer.java:409) ~[teiid-spring-boot-starter-1.7.1.jar:1.7.1]
at org.teiid.spring.autoconfigure.TeiidServer.addDataSource(TeiidServer.java:155) ~[teiid-spring-boot-starter-1.7.1.jar:1.7.1]
at org.teiid.spring.autoconfigure.TeiidPostProcessor.postProcessAfterInitialization(TeiidPostProcessor.java:114) ~[teiid-spring-boot-starter-1.7.1.jar:1.7.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:437) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790) ~[spring-beans-5.3.8.jar:5.3.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) ~[spring-beans-5.3.8.jar:5.3.8]
... 33 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:53737', transport: 'socket'
Process finished with exit code 1
非常感谢提供的任何帮助
添加到pom.xml
<dependency>
<groupId>org.teiid</groupId>
<artifactId>spring-data-postgresql</artifactId>
</dependency>