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

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.

主站蜘蛛池模板: 金平| 阿瓦提县| 福海县| 利川市| 札达县| 双江| 吴江市| 麟游县| 莲花县| 方城县| 崇左市| 来安县| 开化县| 鲁山县| 合川市| 政和县| 固阳县| 常宁市| 云霄县| 江油市| 景德镇市| 奉贤区| 琼海市| 漳州市| 叙永县| 定结县| 于都县| 绥宁县| 沈丘县| 侯马市| 巧家县| 海安县| 商洛市| 新巴尔虎左旗| 丹江口市| 应用必备| 资源县| 赤峰市| 涞源县| 海盐县| 广平县|