DEV Community

WangGithub0
WangGithub0

Posted on

Keep on working on open-source Spring Boot project

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.

Image description

SET SQL_MODE ='IGNORE_SPACE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
Enter fullscreen mode Exit fullscreen mode
  • 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;
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

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)