Learning Java framework # 1 (Mac version)

Developed using Java framework

First of all, open this Eclipse screen.

スクリーンショット 2020-07-12 4.36.31.png

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.

スクリーンショット 2020-07-12 4.50.45.png スクリーンショット 2020-07-12 4.50.54.png

A screen for selecting a weathered will appear. By the way, this time, Eclipse 2020 I'm using the year version.

スクリーンショット 2020-07-12 4.51.08.png

Then select the Spring Starter project.

スクリーンショット 2020-05-24 6.13.45.png

Write the package name and name. (The package name and name are all right!)

スクリーンショット 2020-05-24 6.14.01.png

Next, let's move on to Spring Starter / Dependencies.

スクリーンショット 2020-05-24 6.16.01.png

Spring Boot DevTools MyBatis Framework MySQL Driver Spring Security Thymeleaf Spring web Select and click Finish.

スクリーンショット 2020-05-24 6.28.10.png

On the next screen, just click Finish.

スクリーンショット 2020-05-24 6.28.33.png

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.)

スクリーンショット 2020-07-12 5.53.43.png

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.

スクリーンショット 2020-05-25 4.55.39.png

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.

スクリーンショット 2020-05-25 5.04.39.png

I also have to set Spring security, so I have to set it.

スクリーンショット 2020-05-25 5.07.14.png

Since it can be set in the Java class, use that method.

スクリーンショット 2020-05-25 5.08.31.png

When creating a new class, please decide the class name as you like.

スクリーンショット 2020-05-25 5.09.30.png スクリーンショット 2020-05-25 5.10.11.png スクリーンショット 2020-05-25 5.11.13.png

After entering your name, click Browse Superclass.

スクリーンショット 2020-05-25 5.11.57.png

It inherits Spring's built-in web security, Configear Adapter. Click to select and click OK.

スクリーンショット 2020-05-25 5.13.42.png

Just click Finish.

スクリーンショット 2020-05-25 5.14.23.png

Regarding the code, "This is it! It is better to remember while writing because it is difficult to explain concretely.

スクリーンショット 2020-05-25 5.15.02.png

First, the class that performs the configuration is given a station called Enable Web Security.

スクリーンショット 2020-05-25 5.18.11.png

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.

スクリーンショット 2020-05-25 5.18.11.png スクリーンショット 2020-05-25 5.35.50.png

It's done.

スクリーンショット 2020-05-25 5.39.14.png

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.

スクリーンショット 2020-07-20 8.25.18.png スクリーンショット 2020-07-20 8.25.29.png

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.)

スクリーンショット 2020-07-20 8.38.53.png

OK if it is done like this

スクリーンショット 2020-07-20 8.41.30.png

Next, create a controller class.

スクリーンショット 2020-07-20 8.45.47.png

If you can make it with a class name like this, it's OK (Because I made it earlier, don't make a mistake)

スクリーンショット 2020-07-20 8.46.35.png

After writing the code like this, I'm ready to launch the web application for the time being.

スクリーンショット 2020-07-20 8.47.53.png

Then use Spring boot to launch the application.

スクリーンショット 2020-07-20 10.19.15.png

Tomcat has started

スクリーンショット 2020-07-20 10.22.30.png

Next, let's look at it on the browser.

スクリーンショット 2020-07-20 10.39.17.png

If you enter the password you decided earlier here

スクリーンショット 2020-07-20 10.43.17.png

It opens like this.

スクリーンショット 2020-07-20 10.44.15.png

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

Learning Java framework # 1 (Mac version)
Simplify java version switching (Mac)
Java learning (0)
java framework
For JAVA learning (2018-03-16-01)
Java learning day 5
Java version check
Java framework comparison
Download and install Eclipse (Java) (Mac version)
java learning day 2
[Java] Collection framework
java learning day 1
Java installation (Mac, Homebrew, multiple version control)
Play Framework2.5 (Java) Tips
[Java] Convert PDF version
Install Java on Mac
Java learning 2 (learning calculation method)
java learning (conditional expression)
Java version notation comparison
Java learning memo (method)
Java Learning (1)-Hello World
Mac Java Home Directory
JAVA learning history interface
Switching java version (memorial)
Java learning memo (basic)
[Development] Java framework comparison
Java learning memo (interface)
Java learning memo (inheritance)
Java version control on macOS
Java basic learning content 7 (exception)
Java version 8 and later features
How to lower java version
JAVA learning history interface inheritance
Java learning memo (data type)
How to uninstall Java 8 (Mac)
Java basic learning content 5 (modifier)
Books used for learning Java
4th day of java learning
Java Collections Framework Review Notes
Version control Java with SDKMAN
Java learning memo (logical operator)
Java version control with jenv
Java development environment (Mac, Eclipse)
Java learning memo (abstract class)
Java version change on CentOS
Java installation location for mac
Java Basic Learning Content 8 (Java API)
Java Learning 1 (learning various data types)
Java basic learning content 4 (repetition)
How to switch Java version with direnv in terminal on Mac
Consideration on Java Persistence Framework 2017 (Summary) -1
Consideration on Java Persistence Framework 2017 (6) Ebean
Java learning memo (creating an array)
Java version notation that changes in Java 10
Deep Learning Java from scratch 6.4 Regularization
[Java version] The story of serialization
Ruby environment construction summary ~ mac version ~
Consideration on Java Persistence Framework 2017 (5) Iciql
Java basic learning content 3 (operator / ternary operator)
Play Framework 2.6 (Java) development environment creation
Consideration on Java Persistence Framework 2017 (7) EclipseLink