Spring boot 我正在努力学习春靴。我在将spring boot项目与远程oracle DB连接时遇到错误

Spring boot 我正在努力学习春靴。我在将spring boot项目与远程oracle DB连接时遇到错误,spring-boot,oracle11g,Spring Boot,Oracle11g,o、 h.engine.jdbc.spi.SqlExceptionHelper:SQL错误:1427,SQLState:21000 2020-04-05 13:08:39.334错误25252---[main]o.h.engine.jdbc.spi.SqlExceptionHelper:ORA-01427:单行子查询返回多行 2020-04-05 13:08:39.377警告25252---[main]ConfigServletWebServerApplicationContext:在上下文初始

o、 h.engine.jdbc.spi.SqlExceptionHelper:SQL错误:1427,SQLState:21000 2020-04-05 13:08:39.334错误25252---[main]o.h.engine.jdbc.spi.SqlExceptionHelper:ORA-01427:单行子查询返回多行

2020-04-05 13:08:39.377警告25252---[main]ConfigServletWebServerApplicationContext:在上下文初始化过程中遇到异常-取消刷新尝试:org.springframework.beans.factory.BeanCreationException:创建在类路径资源中定义了名为“entityManagerFactory”的bean时出错[org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]:初始化方法调用失败;嵌套异常为javax.persistence.PersistenceException:[PersistenceUnit:default]无法构建Hibernate会话工厂;嵌套异常为org.Hibernate.exception.DataException:访问元数据表时出错 2020-04-05 13:08:39.377信息25252---[main]com.zaxxer.hikari.HikariDataSource:hikaripol-1-已启动关机。。。 2020-04-05 13:08:39.608信息25252---[main]com.zaxxer.hikari.HikariDataSource:hikaripol-1-关闭完成。 2020-04-05 13:08:39.610信息25252---[main]o.apache.catalina.core.StandardService:停止服务[Tomcat] 2020-04-05 13:08:39.651信息25252---[main]条件评估报告日志监听器:

启动ApplicationContext时出错。若要显示条件报告,请在启用“调试”的情况下重新运行应用程序。 2020-04-05 13:08:39.664错误25252---[main]o.s.boot.SpringApplication:应用程序运行失败

org.springframework.beans.factory.BeanCreationException:创建名为“entityManagerFactory”的bean时出错,该bean在类路径资源[org/springframework/boot/autoconfigure/orm/jpa/hibernatejpacConfiguration.class]:调用init方法失败;嵌套异常为javax.persistence.PersistenceException:[PersistenceUnit:default]无法生成Hibernate SessionFactory;嵌套异常为org.Hibernate.exception.DataException:访问表元数据时出错 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108)~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 位于org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:315)[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在com.tcs.SpringBootMvcDemoApplication输入image description heretion.main(SpringBootMvcDemoApplication.java:27)[classes/:na] 原因:javax.persistence.PersistenceException:[PersistenceUnit:default]无法构建Hibernate SessionFactory;嵌套异常为org.Hibernate.exception.DataException:访问表元数据时出错


从您的例外情况中我可以看出:
org.springframework.beans.factory.BeanCreationException:创建名为“entityManagerFactory”的bean时出错,该bean在类路径资源中定义

通过查看您的代码:
需要使用
@Repository

最好也添加这些依赖项

<dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

mysql
mysql连接器java
运行时
org.springframework.boot
弹簧起动试验
测试
org.junit.vintage
朱尼特老式发动机

我最近也遇到了同样的问题。我重叠了一些依赖项,导致“创建类路径资源中定义的名为“entityManagerFactory”的bean时出错”<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies>