官术网_书友最值得收藏!

Run as Spring Boot

The preceding example can be easily converted to a Spring Boot application by following the ensuing additional steps. This process won't cover many of the trivial steps that we have done previously. You need to have one more configuration file, SpringSecurityConfig.java, the details of which are as follows.

You can create a new file, usually named Run.java, with the following code:

@SpringBootApplication
public class Run {
public static void main(String[] args) {
SpringApplication.run(Run.class, args);
}
}

It's a very simple file with an important annotation in it, @SpringBootApplication. We took away the Spring MVC configuration class and put the following properties in the application.properties file. This is just another way to avoid creating a new Spring MVC configuration file and instead use the properties file:

spring.mvc.view.prefix: /WEB-INF/views/
spring.mvc.view.suffix: .jsp

As earlier, everything else is kept intact. For the full project, refer to the book's GitHub page in the spring-boot-in-memory-basic-authentication project.

Open a command prompt and enter the following command:

mvn spring-boot:run

Open the browser and navigate to http://localhost:8080, and you should be provided with a basic authentication dialog. After successful login, you should be taken to the user home page, as shown earlier.

主站蜘蛛池模板: 石柱| 衡南县| 会昌县| 额敏县| 普安县| 万载县| 台北市| 涡阳县| 格尔木市| 连平县| 额敏县| 安达市| 焦作市| 金阳县| 昔阳县| 扬州市| 永川市| 兴安盟| 互助| 长沙县| 阜新市| 谷城县| 仪陇县| 子洲县| 称多县| 房产| 阳原县| 迁西县| 莫力| 南华县| 隆子县| 衡水市| 曲靖市| 玉林市| 清新县| 台南县| 北京市| 贡山| 中山市| 南涧| 滕州市|