用MySQL替换hsqldb [英] Replace hsqldb with MySQL

查看:169
本文介绍了用MySQL替换hsqldb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用hsqldb配置的Spring REST项目. 我想将其更改为MySQL. 我已经安装并正在运行MySQL服务器,但是我不知道如何修改此pom:

I have a Spring REST project configured with hsqldb. I would like to change it to MySQL. I have MySQL server installed and running, but I don't know how to modify this pom:

    <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <scope>runtime</scope>
    </dependency>

PS .:我正在谈论的项目是"Spring REST"书的源代码: http://www.apress.com/9781484208243

PS.: Project im talking about comes as a source code for 'Spring REST' book: http://www.apress.com/9781484208243

源代码下载链接:

http://www.apress.com/downloadable/download/sample /sample_id/1704/

推荐答案

据我所知,您正在此上使用Spring Boot,因此您可以轻松地更改数据库,从而从以下位置更改驱动程序依赖性:

As far I see you are using Spring Boot on this, so you can easy change the databases changing the drivers dependencies from:

 <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <scope>runtime</scope>
</dependency>

收件人

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

驱动程序版本将是父pom上的版本. 然后在属性上指定参数

The driver version will be version on parent pom. Then specify the parameters on properties

spring.datasource.url=jdbc:mysql://localhost:port/yourdb
spring.datasource.username=dbuser
spring.datasource.password=dbpass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver # we can ommit this if we want, Spring Boot will deduce based on the classpath

有关数据库的更多配置,请参见附录

For more configuration on databases you can see the properties available on appendix here

这篇关于用MySQL替换hsqldb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆