Java 手动将mySQL连接到eclipse/Spring启动
我想问一下,在使用eclipse和spring引导时,是否需要指定SQL文件的路径?我遇到了相同的错误Java 手动将mySQL连接到eclipse/Spring启动,java,mysql,spring,eclipse,spring-boot,Java,Mysql,Spring,Eclipse,Spring Boot,我想问一下,在使用eclipse和spring引导时,是否需要指定SQL文件的路径?我遇到了相同的错误无法确定数据库类型NONE的嵌入式数据库驱动程序类。我相信所有的设置都是正确的,但问题是我从未告诉eclipse我的数据库在哪里 我有一个属性文件,其中说明: spring.jpa.hibernate.ddl-auto=create-drop spring.datasource.url=jdbc:mysql://localhost:3306/db_example spring.datasourc
无法确定数据库类型NONE的嵌入式数据库驱动程序类
。我相信所有的设置都是正确的,但问题是我从未告诉eclipse我的数据库在哪里
我有一个属性文件,其中说明:
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.url=jdbc:mysql://localhost:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePassword
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
这是它找到db_示例的一种方法吗?当我开始我的项目时,它是否应该在线?当我转到localhost:3306时,它还显示一个错误。我已经两天没能解决这个问题了,而且我对编程还很陌生,所以请容忍我
从属关系(包括HikariCP)
编辑2
我的路径截图
编辑3
移动文件夹后的错误消息如下:
2017-07-28 11:40:20.348 WARN 10944 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
请将
spring.datasource.drivercassname=com.mysql.jdbc.Driver
更改为此spring.datasource.Driver类名=com.mysql.jdbc.Driver
。
您的最终数据库配置可能如下所示:
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
spring.datasource.url=jdbc:mysql://localhost:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePassword
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
另外,请将您的pom.xml文件dependencies
更新到此文件,并在eclipse中运行maven更新
:
<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>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
org.springframework.boot
spring引导启动器数据jpa
org.springframework.boot
SpringBootStarterWeb
mysql
mysql连接器java
org.springframework.boot
弹簧起动试验
测试
请将spring.datasource.drivercassname=com.mysql.jdbc.Driver
更改为此spring.datasource.Driver类名=com.mysql.jdbc.Driver
。
您的最终数据库配置可能如下所示:
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
spring.datasource.url=jdbc:mysql://localhost:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePassword
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
另外,请将您的pom.xml文件dependencies
更新到此文件,并在eclipse中运行maven更新
:
<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>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
org.springframework.boot
spring引导启动器数据jpa
org.springframework.boot
SpringBootStarterWeb
mysql
mysql连接器java
org.springframework.boot
弹簧起动试验
测试
我在资源文件夹中没有看到您的应用程序.properties
。您的应用程序.properties
在测试环境中。我不会那样工作 我在资源文件夹中看不到您的应用程序.properties
。您的应用程序.properties
在测试环境中。我不会那样工作 如您在其他问题中所述,您需要包括一个数据源
实现。你还没有提供一个。。。添加类似于依赖项的内容。您在Maven/Gradle中添加了mySQL连接器依赖项了吗?我添加了HiakriCP和mySQL,问题仍然存在!你确定你的application.properties文件在资源文件夹下吗?你能发布你的应用程序结构树的屏幕截图吗?复制并粘贴你的应用程序属性文件到你的src_main_资源文件夹中,正如你在其他问题中所述,你需要包括一个数据源
实现。你还没有提供一个。。。添加类似于依赖项的内容。您在Maven/Gradle中添加了mySQL连接器依赖项了吗?我添加了HiakriCP和mySQL,问题仍然存在!你确定你的application.properties文件在资源文件夹下吗?你能发布你的应用程序结构树的屏幕截图吗?复制并粘贴你的应用程序属性文件到你的src_main_资源文件夹中。你能用上面的配置更新依赖项并运行maven更新吗?这样做了,还是同一个错误。。有什么我应该添加到我的应用程序吗?我目前有:@SpringBootApplication@ComponentScan({“io.msela”})@EntityScan(“io.msela.springbootstarter”)@EnableJpaRepositories(basePackageClasses=EmployeeRepository.class)在使用上述配置更新后,您是否仍会遇到此错误无法确定数据库类型的嵌入式数据库驱动程序类NONE
。您的springboot应用程序似乎一直在使用Derby Db(嵌入式)。现在您已经删除了它,您应该在eclipse中更新您的maven:右键单击您的应用=>maven=>update。@Asker更新pom.xml后是否运行了maven update能否请您更新依赖项并使用上述配置运行maven更新完成了此操作,仍然是相同的错误。。有什么我应该添加到我的应用程序吗?我目前有:@SpringBootApplication@ComponentScan({“io.msela”})@EntityScan(“io.msela.springbootstarter”)@EnableJpaRepositories(basePackageClasses=EmployeeRepository.class)在使用上述配置更新后,您是否仍会遇到此错误无法确定数据库类型的嵌入式数据库驱动程序类NONE
。您的springboot应用程序似乎一直在使用Derby Db(嵌入式)。现在您已经删除了它,您应该在eclipse中更新您的maven:右键单击您的应用=>maven=>update。@Asker更新pom.xmlOh good后是否运行了maven update,所以这就是问题所在!但是现在它显示了一系列错误,而不是以前的错误,说它无法加载驱动程序:/但是我假设您已经纠正了:spring.datasource.drivercassname=com.mysql.jdbc.driver,正如另一个用户所指出的那样?是的,我已经纠正了。现在是spring.datasource.driver class name=com.mysql.jdbc.driver我需要对maven或属性文件做些什么,还是maven应该安装并升级maven就足够了?答案简短但高效:)哦,天哪,这就是问题所在!但是现在它显示了一系列错误,而不是以前的错误,说它无法加载驱动程序:/但是我假设您已经纠正了:spring.datasource.drivercassname=com.mysql.jdbc.driver,正如另一个用户所指出的那样?是的,我已经纠正了。现在是spring.datasource.driver class name=com.mysql.jdbc.driver我需要对maven或