First of all, open this Eclipse screen.
I will make it where it is painted black. (I made it black earlier, so I'm hiding it ...)
Then in Project Eclipse Roller, right click and select New, Other.
A screen for selecting a weathered will appear. By the way, this time, Eclipse 2020 I'm using the year version.
Then select the Spring Starter project.
Write the package name and name. (The package name and name are all right!)
Next, let's move on to Spring Starter / Dependencies.
Spring Boot DevTools MyBatis Framework MySQL Driver Spring Security Thymeleaf Spring web Select and click Finish.
On the next screen, just click Finish.
When you're done, you've created a project in the project explorer on the first screen. (The project below is irrelevant, so please ignore it.)
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, I have to tell the connection information with MySQL to Tomcat of the application server, so when I created the Spring Starter project project, it was already in the source main, and the property file called Application Properties under Resource Is there is.
Describe the connection settings with the database here. (It's better to remember the code) For the settings, write the code according to your own environment settings.
I also have to set Spring security, so I have to set it.
Since it can be set in the Java class, use that method.
When creating a new class, please decide the class name as you like.
After entering your name, click Browse Superclass.
It inherits Spring's built-in web security, Configear Adapter. Click to select and click OK.
Just click Finish.
Regarding the code, "This is it! It is better to remember while writing because it is difficult to explain concretely.
First, the class that performs the configuration is given a station called Enable Web Security.
I'm overloading the Configear method from a superclass web security Configear adapter, but there are several Configear methods that have uses, but this time I just want to start them, so the Authentication Manager Overrides two methods, the Configear method, which takes an argument called Builder, and the Confugiar method, which takes an object called HTTP Security.
It's done.
If you think of the Confugia method, which takes an object called Authentication Manager Builder as an argument, as a method for determining the user's recognition method, there is no problem.
There are methods for managing user information using a DB (database) and authentication methods using LDAP (Lightweight Directory Access Protocol), but this time we will use the database. I just want to make it work easily, so I will set it in-memory.
Once this is done, then create a new HTML file from here and elsewhere. (Since I could not put it well, I will omit it and put it. Please name the HTML file index.html.)
OK if it is done like this
Next, create a controller class.
If you can make it with a class name like this, it's OK (Because I made it earlier, don't make a mistake)
After writing the code like this, I'm ready to launch the web application for the time being.
Then use Spring boot to launch the application.
Tomcat has started
Next, let's look at it on the browser.
If you enter the password you decided earlier here
It opens like this.
You were able to create Spring boot and Spring security together.
I wrote it like this, but there is a video that you referred to (although it may be a little different), so I think it will be easier to understand if you make it while watching this.
YouTube
TechShare channel
https://www.youtube.com/watch?v=IWH_EZwQhSY&t=1136s
Recommended Posts