springboot使用Spring Security OAuth2做权限控制 下载本文

内容发布更新时间 : 2024/11/9 14:46:41星期一 下面是文章的全部内容请认真阅读。

springboot使用Spring Security+OAuth2做权限控制

源码地址:

https://github.com/li5454yong/springboot-security-oauth2.git

首先来看项目结构这个项目中用到了三张表,运行项目会自动在数据库建立这三张表。

1、pom依赖XHTML

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 <parent>

<groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <repositories> <repository>

<id>aliyunRepository</id> <name>myRepository</name> <url>http://maven.aliyun.com/nexus/content/groups/public

/</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<java.version>1.7</java.version> <spring-security-oauth2.version>2.0.3.RELEASE</spring-security-oauth2.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-redis</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency>

<groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.security.oauth</groupId>

<artifactId>spring-security-oauth2</artifactId> </dependency> <dependency> <groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId> <scope>runtime</scope>

</dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies>