简体   繁体   English

spring 启动连接到 localhost 数据库

[英]spring boot connection to localhost database

Is it possible to connect a database from mamp server(localhost) using a spring boot app in eclipse and display data from it?是否可以使用eclipse中的spring boot应用程序从mamp服务器(本地主机)连接数据库并显示来自它的数据? Or how does it work, because I have no idea how to implement that?或者它是如何工作的,因为我不知道如何实现它?

 spring.datasource.url=jdbc:mysql://localhost/dbtuts
 spring.datasource.username=root
 spring.datasource.password=root
 spring.datasource.driver-class-name=com.mysql.jdbc.Driver
 spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

this is what, I've been using for application.properties这就是,我一直在用于 application.properties

Following settings seem to work fine for me.以下设置对我来说似乎工作正常。

spring.datasource.url=jdbc:mysql://localhost:8889/test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

I am using WAMP server 3.0.6我正在使用 WAMP 服务器 3.0.6
Default port for MySql is 3306 so the following works for me MySql 的默认端口是 3306,所以以下对我有用

spring.datasource.url= jdbc:mysql://localhost:3306/DBname
spring.datasource.username=dbusername
spring.datasource.password=dbpassword
spring.jpa.hibernate.ddl-auto=create-drop

In case of anyone using MySQL from MAMP.如果有人从 MAMP 使用 MySQL。 Following Configuration worked for me.以下配置对我有用。

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:8889/join_test?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM