mybatis配置pgsql
时间: 2023-08-16 12:07:25 浏览: 122
pgsql中使用mybatis生成实体类
根据引用\[1\]和引用\[2\]的内容,配置Mybatis连接pgsql数据库的步骤如下:
1. 在项目的pom.xml文件中添加Mybatis和pgsql的相关依赖:
```xml
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
```
2. 在application.yml或application.properties配置文件中修改数据库连接信息:
```yaml
spring:
datasource:
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://127.0.0.1:5432/your_database_name
username: your_username
password: your_password
```
3. 如果需要使用驼峰命名法的转换,可以在配置文件中添加以下配置:
```yaml
mybatis:
configuration:
mapUnderscoreToCamelCase: true
```
4. 在启动类上添加@MapperScan注解,指定Mybatis的Mapper接口所在的包路径:
```java
@MapperScan("your.mapper.package")
```
请根据你的具体情况修改上述配置中的数据库连接信息和包路径。
#### 引用[.reference_title]
- *1* *3* [Spring Mybatis连接pgsql配置步骤](https://blog.csdn.net/u010886217/article/details/102996094)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [springboot(基本配置)+mybatis -》pgsql-》 excel](https://blog.csdn.net/HuangMingJun95/article/details/123403525)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文