Now your app is configured to use Hibernate with MySQL. These properties are discussed in more depth in the Spring Boot Persistence cheatsheet. If you've changed those, be sure to update the datasource URL accordingly. We've assumed that you are using the default MAMP port settings. We recommended using "cheese-mvc" and "cheese" respectively. The username and password, along with the database name in the datasource URL, should match the values you used when creating your database in MAMP. To check what the MySQL port is set to under MAMP, check the MAMP preferences. If you are using Windows or Linux, you may need to set your port in the second line to 3306. # stripped before adding them to the entity manager) # Use .* for Hibernate native properties (the prefix is # Hibernate ddl auto (create, create-drop, update) Make sure these lines are in that file: # Database connection settings The database connection needs to be configured via src/main/resources/application.properties. In settings other than Spring Boot, you'd likely work with Hibernate much more directly. We'll primarily work with Java Persistence API annotations, but you should know that Hibernate provides the implementation for most of these behaviors behind the scenes. We won't talk explicitly about Hibernate very much, since we won't need to work with it directly in most situations. The spring-boot-starter-data-jpa artifact includes the Hibernate ORM framework. Make sure these lines are in the dependencies section of your adle: compile(':spring-boot-starter-data-jpa') But if you want to keep using the code that you have been building while coding along with the videos, then be sure to add the lines and files below. This branch has the code that we will start working from during our first cheese-mvc related video lesson for this class. In the case of our cheese-mvc application, the following lines and files will already be included in the video-jpa-start branch of the LaunchCodeEducation's cheese-mvc repository. These steps will need to be carried out for each application that you want to make work with a database. If you don't do this, you'll have to create a database and set permissions manually. In the case of your cheese-mvc application, it is a good idea to use the username "cheese-mvc" and the password "cheese", so that the starting code for the video lessons works properly.Īnd be sure to check the first checkbox under Database for user account. Just be sure that you don't use the same password on a production database if you deploy your application! For local development, it's acceptable to use a simple password. Set the Host name field to Local and set a password. A good pattern to follow is that you should have a different user for each application, and the username should match the name of your application. From the page that opens up in your browser, select Tools > phpMyAdmin.įill out the resulting form with info for your application. Once that button has turned green, choose Open Start Page. From the launcher window, select Start Servers. You might also install phpMyAdmin or another MySQL management application. If you use Linux, you should install, at a minimum, the MySQL 5.x package for your system. Do not install MAMP Pro, which is not free. If you didn't already install MAMP in Unit 2, install MAMP for your system. While we won't use Apache and PHP directly, they'll provide us with an interface to work with our MySQL server, called phpMyAdmin. The acronym MAMP stands for Mac / Apache / MySQL / PHP, and despite the first term, there is a version for Windows as well. MAMP is a suite of tools useful for developers. This article walks you through the steps needed to setup a Spring Boot application to use MySQL for local development.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |