环境:springboot、jpa
数据库:阿里云mysql数据库
数据库连接字符串:
问题描述:在自己部署的mysql数据库可以正常访问,没有问题,但是切换到阿里mysql数据库上出现JPA Connection is read-only. Queries leading to data modification are not allowed 网上查询了好多,也没有找到解决方法,
application.properties不指定spring.datasource.type值 spring Boot默认的数据源是:org.apache.tomcat.jdbc.pool.DataSource
最后解决方法:
在使用阿里云的数据库需要指定type
pom.xml
<!-- DataSource Pool -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.18</version>
</dependency>
application.properties 使用阿里的数据库连接池
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource