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

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.

主站蜘蛛池模板: 巴东县| 大港区| 卓资县| 莆田市| 富源县| 定兴县| 肥东县| 八宿县| 普定县| 资源县| 金门县| 沧州市| 满洲里市| 富锦市| 武宣县| 米易县| 杭锦后旗| 乌鲁木齐市| 麻阳| 鄯善县| 梧州市| 鹤壁市| 游戏| 黔江区| 沁源县| 简阳市| 葫芦岛市| 兖州市| 京山县| 体育| 永定县| 九龙县| 延边| 宜君县| 高唐县| 望江县| 廉江市| 永州市| 定南县| 手游| 临汾市|