After trying to find a runnable spring boot project for beginner.
I began to fix another bug for this E-commerce-project-springBoot project.
In order to login the project, I had to create some base data in the database, I did it according to the mysql document, but I got some errors, so I tried to revised them.
-
ERROR 4031 (HY000): The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.
Because the 'NO_AUTO_CREATE_USER' mode is not supported, so I deleted it from the list of modes.
SET SQL_MODE ='IGNORE_SPACE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
- Register met error "Duplicate entry '1' for key 'customer.PRIMARY'. After searching, I found running the basedata.sql script on the database has manually inserted records with IDs '1' and '2' into the CUSTOMER table. Since the code use the GenerationType.AUTO strategy for ID generation, MySQL is attempting to automatically generate the next available ID when try to insert a new record. However, this conflicts with the existing IDs manually inserted before.
So I set:
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
I also add try catch for addUser since sometimes add action failed and updated the README, make it much clearly.
During this process, I acquired fundamental knowledge of Spring Boot, MySQL, Maven, and IntelliJ. I gained insights into connecting Java with databases, utilizing JPA for data persistence, and enhancing my understanding of Java development. Despite my limited experience in Java, I recognize there is still much to learn and explore. This experience served as a valuable foundation, highlighting areas for improvement and offering a glimpse into the vast landscape of Java development that lies ahead for me.
Top comments (0)