本文介绍了Spring Boot - 无法确定数据库类型为NONE的嵌入式数据库驱动程序类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! [INFO]警告:嵌套在org中.springframework.beans.factory.BeanCreationException:创建名为'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration'的bean时出错:注入自动装配依赖失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装入字段:private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource;嵌套异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[org / springframework / boot / autoconfigure / jdbc / DataSourceAutoConfiguration $ NonEmbeddedConfiguration.class]中定义名称为'dataSource'的bean时出错:bean的实例化失败;嵌套异常是org.springframework.beans.factory.BeanDefinitionStoreException:工厂方法[public javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration $ NonEmbeddedConfiguration.dataSource()]引发异常;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法确定数据库类型为NONE的嵌入式数据库驱动程序类。如果您想要嵌入式数据库,请将支持的数据库放在类路径中。: [INFO] org.springframework.beans.factory.BeanCreationException:无法确定数据库类型为NONE的嵌入式数据库驱动程序类。如果你想要一个嵌入式数据库,请在类路径中放一个支持的数据库。 [信息]在org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:91) [信息]在org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration $ NonEmbeddedConfiguration。数据源(DataSourceAutoConfiguration.java:100) [信息]在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) [信息]在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)$ [INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [INFO] at java.lang.reflect.Method.invoke(Method.java:606) [ (简单实例策略)。 .java:166) [INFO] at org.springframework.beans.factory.support.ConstructorResolver $ 3.run(ConstructorRe [INFO] at java.security.AccessController.doPrivileged(Native Method) [INFO] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java :577) [INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094) [INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .createBeanInstance(AbstractAutowireCapableBeanFactory.java:989) [INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) [INFO] at org.springframework.beans .factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) [信息]在org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:3 04) [信息]在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) [INFO]在org.springframework.beans.factory.support.AbstractBeanFactory。 doGetBean(AbstractBeanFactory.java:300) [INFO] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) [INFO] at org.springframework.beans。 factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017) [信息]在org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960) [INFO]在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredAnnotationBeanPostProcessor.jav(org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858) [INFO] a:480) [INFO] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) [INFO] at org.springframework.beans.factory.annotation。 AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) [INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) [INFO] at org.springframework。 beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) [信息]在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) [INFO ] at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:304) [INFO] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSi [INFO] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) [INFO] at org.springframework.beans.factory。 support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) [信息]在org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:370) [INFO]在有机springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094) [INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989) [INFO]在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) [INFO]在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory。 createBean(AbstractAutowireCapableBeanFactory.java:475) [信息]在org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:304) [INFO]在org.springframework.beans .factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) [信息]在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) [INFO]在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) [信息]在org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:973) [INFO]在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:750) [信息]在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) [信息]在org.spr [INFO] at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [INFO] at org.springframework。 boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:142) [信息]在org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener.initWebApplicationContext(SpringBootContextLoaderListener.java:60) [INFO ] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [INFO] at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548) [INFO] at org.mortbay.jetty.servlet.Context.startContext(Context.java:136) [INFO] at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250) [INFO] at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) [INFO] at org.mortbay.jetty.webapp.WebAppCo ntext.doStart(WebAppContext.java:467) [信息]在org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [信息]在org.mortbay.jetty.handler。 HandlerWrapper.doStart(HandlerWrapper.java:130) [INFO] at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [INFO] at org.mortbay.jetty.handler。 HandlerWrapper.doStart(HandlerWrapper.java:130) [INFO] at org.mortbay.jetty.Server.doStart(Server.java:224) [INFO] at org.mortbay.component.AbstractLifeCycle。启动(AbstractLifeCycle.java:50) [com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:249)上的[INFO] [com.google.appengine上的INFO]。 tools.development.AbstractContainerService.startup(AbstractContainerService.java:306) [INFO] at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26) [INFO] at com.google.appengine.tools .development.AbstractModule.startup(AbstractModule.java:79) [INFO] at com.google.appengine.tools.development.Modules.startup(Modules.java:88) [INFO] at com .google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:254) [INFO] at com.google.appengine.tools.development.DevAppServerImpl.access $ 000(DevAppServerImpl.java:47) [INFO] at com.google.appengine.tools.development.DevAppServerImpl $ 1.run(DevAppServerImpl.java:212) [INFO] at com.google.appengine.tools.development.DevAppServerImpl $ 1.run( DevAppServerImpl.java:210) java.security.AccessController.doPrivileged(本地方法)的[INFO] com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java)的[INFO] :210) [INFO]位于com.google.appengine.tools.development.DevAppServerMain $ StartAction.apply(DevAppServerMain.java:277) [INFO]位于com.google.appengine.tools.util .Parser $ ParseResult.applyArgs(Parser.java:48) [INFO]位于com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:219) [INFO]位于com.google.appengine.tools.development.DevAppServerMain.main( DevAppServerMain.java:210) 我相信我有正确的 datanucleus组合-appengine 和 datanucleus jar: JPA App Config:@Configuration@EnableJpaRepositories("demo.core.entity")@EnableTransactionManagementclass JpaApplicationConfig { private static final Logger logger = Logger .getLogger(JpaApplicationConfig.class.getName()); @Bean public AbstractEntityManagerFactoryBean entityManagerFactory() { logger.info("Loading Entity Manager..."); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setPersistenceUnitName("transactions-optional"); return factory; } @Bean public PlatformTransactionManager transactionManager() { logger.info("Loading Transaction Manager..."); JpaTransactionManager txManager = new JpaTransactionManager(); txManager.setEntityManagerFactory(entityManagerFactory().getObject()); return txManager; } @Bean public PersistenceExceptionTranslator persistenceExceptionTranslator() { return new OpenJpaDialect(); }}Application.java@Configuration@ComponentScan@EnableAutoConfiguration@RestControllerpublic class Application { private static final EntityManagerFactory INSTANCE = Persistence.createEntityManagerFactory("transactions-optional"); public static void main(String[] args) { SpringApplication.run(Application.class, args); } @RequestMapping("/") public String home() { return "Hello World"; }}POM:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="..."> <modelVersion>4.0.0</modelVersion> <groupId>org.demohq</groupId> <artifactId>demo-boot</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>demo-boot</name> <description>Demo project</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.1.0.BUILD-SNAPSHOT</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-legacy</artifactId> <version>1.1.0.BUILD-SNAPSHOT</version> </dependency> <!--<dependency>--> <!--<groupId>net.kindleit</groupId>--> <!--<artifactId>gae-runtime</artifactId>--> <!--<version>${gae.version}</version>--> <!--<type>pom</type>--> <!--<scope>provided</scope>--> <!--</dependency>--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> </dependency> <!--<dependency>--> <!--<groupId>org.hsqldb</groupId>--> <!--<artifactId>hsqldb</artifactId>--> <!--<scope>runtime</scope>--> <!--</dependency>--> <dependency> <groupId>com.google.appengine</groupId> <artifactId>appengine-api-labs</artifactId> <version>${gae.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>com.google.appengine</groupId> <artifactId>appengine-api-stubs</artifactId> <version>${gae.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>com.google.appengine</groupId> <artifactId>appengine-testing</artifactId> <version>${gae.version}</version> <scope>test</scope> </dependency> <!-- DataNucleus --> <dependency> <groupId>org.datanucleus</groupId> <artifactId>datanucleus-api-jpa</artifactId> <version>${datanucleus.jpa.version}</version> </dependency> <dependency> <groupId>org.datanucleus</groupId> <artifactId>datanucleus-core</artifactId> <version>${datanucleus.jpa.version}</version> </dependency> <dependency> <groupId>org.datanucleus</groupId> <artifactId>datanucleus-enhancer</artifactId> <version>${datanucleus.jpa.version}</version> </dependency> <dependency> <groupId>com.google.appengine.orm</groupId> <artifactId>datanucleus-appengine</artifactId> <version>${datanucleus.version}</version> <!-- Need to exclude the enhancer since it interfere with the enhancer plugin. --> <exclusions> <exclusion> <groupId>org.datanucleus</groupId> <artifactId>datanucleus-enhancer</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>javax.jdo</groupId> <artifactId>jdo-api</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-jpa_2.0_spec</artifactId> <version>1.1</version> </dependency> <!-- OpenJPA --> <dependency> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa-persistence</artifactId> <version>2.3.0</version> </dependency> </dependencies> <properties> <start-class>demo.Application</start-class> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.7</java.version> <m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot> <datanucleus.jpa.version>3.1.1</datanucleus.jpa.version> <datanucleus.version>2.1.2</datanucleus.version> <gae.version>1.8.8</gae.version> <gae.home>${settings.localRepository}/com/google/appengine/appengine-java-sdk/${gae.version}/appengine-java-sdk/appengine-java-sdk-${gae.version}</gae.home> <gae.application.version>test</gae.application.version> <!--<org.springframework-version>4.0.5.RELEASE</org.springframework-version>--> </properties> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!-- <plugin> <groupId>net.kindleit</groupId> <artifactId>maven-gae-plugin</artifactId> <version>0.9.6</version> <dependencies> <dependency> <groupId>net.kindleit</groupId> <artifactId>gae-runtime</artifactId> <version>${gae.version}</version> <type>pom</type> </dependency> </dependencies> </plugin> --> <plugin> <groupId>com.google.appengine</groupId> <artifactId>appengine-maven-plugin</artifactId> <version>${gae.version}</version> <configuration> <enableJarClasses>false</enableJarClasses> </configuration> </plugin> <plugin> <artifactId>maven-release-plugin</artifactId> <configuration> <goals>gae:deploy</goals> </configuration> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat6-maven-plugin</artifactId> <version>2.0</version> <configuration> <path>/</path> </configuration> </plugin> <plugin> <groupId>org.datanucleus</groupId> <artifactId>maven-datanucleus-plugin</artifactId> <version>${datanucleus.jpa.version}</version> <configuration> <api>JPA</api> <!--<mappingIncludes>**/entity/*.class</mappingIncludes>--> <verbose>true</verbose> </configuration> <dependencies> <dependency> <groupId>org.datanucleus</groupId> <artifactId>datanucleus-core</artifactId> <version>${datanucleus.jpa.version}</version> </dependency> </dependencies> <executions> <execution> <phase>compile</phase> <goals> <goal>enhance</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <profiles> <!-- We can configure our integration server to activate this profile and perform gae:deploy, thus uploading latest snapshot to the http://1.latest.<applicationName>.appspot.com automatically --> <profile> <id>integration-build</id> <properties> <gae.application.version>stage</gae.application.version> </properties> </profile> <!-- This profile will activate automatically during release and upload application to the http://2.latest.<applicationName>.appspot.com (We might want to set the 2nd version as our applications Default version to be accessible at http://<applicationName>.appspot.com) --> <profile> <id>release-build</id> <activation> <property> <name>performRelease</name> <value>true</value> </property> </activation> <properties> <!-- During release, set application version in appengine-web.xml to 2 --> <gae.application.version>release</gae.application.version> </properties> </profile> </profiles> <repositories> <repository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>http://repo.spring.io/snapshot</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>http://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>http://repo.spring.io/snapshot</url> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>http://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories></project>I wonder what could be missing in my app? I followed the instruction from here Using Spring Data JPA on Google Appengine 解决方案 You haven't provided Spring Boot with enough information to auto-configure a DataSource. To do so, you'll need to add some properties to application.properties with the spring.datasource prefix. Take a look at DataSourceProperties to see all of the properties that you can set.You'll need to provide the appropriate url and driver class name:spring.datasource.url = …spring.datasource.driver-class-name = … 这篇关于Spring Boot - 无法确定数据库类型为NONE的嵌入式数据库驱动程序类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!