Spring Boot集成Spring Security
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring Boot集成Spring Security相关的知识,希望对你有一定的参考价值。
1.pom.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>activiti.demo</groupId>
<artifactId>activiti-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>activiti-demo</name>
<description>spring-activiti-demo</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>1.5.6.RELEASE</version>
</dependency>
<!--<dependency>-->
<!--<groupId>mysql</groupId>-->
<!--<artifactId>mysql-connector-java</artifactId>-->
<!--<version>5.1.35</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
</project>
2.创建控制器
package com.springboot.demo.controller;
import org.springframework.web.bind.annotation.*;
/**
- @ClassName HelloController
- @Description TODO
- @Author yunshuodeng
- @Date 2019-05-05 15:41
- @Version 1.0br/>**/
@RestController
@RequestMapping("/hello")
public class HelloController {br/>@GetMapping
public String hello(){
System.out.println("hello world");
return "hello world";
}
}
3.启动程序
package com.springboot.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/** - @ClassName ProviderApplication
- @Description 提供者主入口程序
- @Author yunshuodeng
- @Date 2019-01-21 10:34
- @Version 1.0br/>**/
@SpringBootApplication
public class ProviderApplication {
public static void main(String[] args){
SpringApplication.run(ProviderApplication.class,args);
}
}
以上是关于Spring Boot集成Spring Security的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot 桌面独立应用程序中的 Apache Shiro