Development using Java framework
First of all, open this Eclipse screen.
I will make it where it is painted black. (I hide it because I made it first because I painted it black.)
Next, right-click on the Project Eclipse Roller and select New, Other.
The screen for selecting the weather appears. By the way, this time, Eclipse 2020 I am using the version.
Then select the Spring Starter Project.
Write the package name and name. (The package name and name are all right!)
Now let’s move on to the Spring Starter/Dependencies.
Spring Boot DevTools MyBatis Framework MySQL Driver Spring Security Thymeleaf Spring web Select and click Finish.
Click Finish as it is on the next screen.
When completed, the project is created in the project explorer on the first screen. (Please ignore the projects below as they are not relevant.)
I want to go to the point where the Web application can be started, so I have to make some settings before that, so I will proceed based on the explanation.
First of all, since it is necessary to tell Tomcat of the application server about the connection information with MySQL, at the time of creating the Spring Starter Project project, the source file is already in the source main and the property file called application property under the resource is. there is.
Describe the connection settings with the database here. (It is better to remember the code) For the setting, write the code according to your own environment setting.
You also have to set Spring security, so you have to set it.
Since it can be set in Java class, that method is used.
When creating a new class, please decide the class name as you like.
Once you have filled in your name, click on the superclass reference.
It inherits Spring’s built-in web security, the Comfy Gear Adapter. Click to select, then click OK.
Just click Finish.
Regarding the code, “This is it! Because it is difficult to explain in detail, it’s better to learn it while writing.
First of all, the class that performs the configuration has an annotation called Enable Web Security.
I’m overloading the Comfy Gear method from the super class Web Security Comfy Gear method. There are several Comfy Gear methods, but there are some uses, but this time I just want to start it, so I’m just going to use the authentication manager Overrides the configure method that takes a builder argument and the configure method that takes an HTTP security object as an argument.
This is done.
There is no problem if you consider the Confugia method that takes an object called the Authentication Manager Builder as an argument to determine the recognition method of the user.
There is an authentication method that uses DB (database) to manage user information and LDAP (Lightweight Directory Access Protocol), but this time we will use the database. I just want to operate it easily, so I will set it in memory.
If you can do this, then create a new HTML file from here and elsewhere. (Because I could not put it well, please omit it and put it as the HTML file name index.html.)
OK if done like this
Next, create a controller class.
If you can create it with a class name like this, Ok (Because I made it first, don’t make a mistake)
After writing the code like this, we’re ready to launch the web application.
Then use Spring boot to start the application.
Tomcat has started
Next, let’s see it on the browser.
If you enter the password you decided earlier here
It opens like this.
You could make Spring boot and Spring security together.
I wrote it like this, but (I think it may be a little different) I have a video that you refer to, so I think it will be easier to understand while making it while watching this.