- Chênh lệch múi giờ 14 giờ giữa giao diện và cơ sở dữ liệu
Thêm tham số múi giờ vào chuỗi kết nối JDBC:
jdbc:mysql://localhost:3306/ten_database?useTimezone=true&serverTimezone=GMT%2B8
- PageHelper không hoạt động
Cập nhật dependency trong pom.xml:
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.5</version> </dependency> - IDEA không tự động làm mới HTML
Cấu hình trong IntelliJ IDEA:
- File → Settings → Build, Execution, Deployment → Compiler → Enable "Build project automatically"
- Nhấn Ctrl+Shift+Alt+/ → Chọn Registry → Kích hoạt "compiler.automake.allow.when.app.running"
- Lỗi gạch chân đỏ trong Maven Dependencies
Thực hiện tuần tự:
- Maven clean
- Cắt dependency từ pom.xml → Lưu
- Maven clean lần nữa
- Dán dependency lại → Lưu
- DataSource không tải driver cơ sở dữ liệu
Sao chép thủ công vào thư mục cấu hình:
C:\Users\tai_khoan\.IntelliJIdea2019.2\config\jdbc-drivers\MySQL Connector\J 8\8.0.15
Yêu cầu 2 file: mysql-connector-java-8.0.15.jar và mysql-connector-license.txt
- Toàn bộ phương thức Test thất bại do lỗi biên dịch
Kiểm tra lỗi cú pháp và cấu trúc mã nguồn trước khi chạy kiểm thử
- Cảnh báo trùng lặp mapper trong MyBatis
Log cảnh báo:
Skipping MapperFactoryBean - Bean already defined with the same name! No MyBatis mapper was found in package
Giải pháp: Đảm bảo mỗi gói mapper chỉ được quét một lần
- Lỗi "Invalid bound statement" trong MyBatis
Bổ sung cấu hình tài nguyên trong pom.xml:
<resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> </resources> - Hiển thị câu lệnh SQL MyBatis
Thêm cấu hình trong application.yml:
mybatis: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - Xung đột bean trong Spring Boot
Kích hoạt ghi đè bean trong application.yml:
spring: main: allow-bean-definition-overriding: true
Giải quyết các sự cố thường gặp trong phát triển Java
Đăng vào ngày 26 tháng 6 lúc 22:05