【SpringSecurity+OAuth2+JWT入门到实战】1.项目介绍和创建
项目结构
- spring-security # 主模块
- spring-security-core # 核心业务逻辑
- spring-security-browser # 浏览器完全特定代码
- spring-security-app # app相关特定代码
- spring-security-demo # 样例程序 用来写例子
项目依赖关系
spring-security-demo 依赖 spring-security-browser和spring-security-app
spring-security-browser 依赖 spring-security-core
pring-security-app 依赖 spring-security-core
创建项目
按照上面的依赖关系去创建项目,本项目使用IDEA开发工具
创建spring-security主项目
删除其他无用目录只留pom文件
创建spring-security-core核心业务逻辑项目
创建spring-security-browser浏览器完全特定代码项目
创建spring-security-app 相关特定代码项目
创建spring-security-demo 样例程序项目
到此项目全部创建完成。
项目依赖
spring-security项目pom依赖
<?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>com.spring.security</groupId>
<artifactId>spring-security</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>security</name>
<description>权限认证系统</description>
<properties>
<spring.security>1.0.0-SNAPSHOT</imooc.security>
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
<spring-platform.version>Cairo-SR8</spring-platform.version>
<spring-cloud.version>Hoxton.SR1</spring-cloud.version>
<security.oauth.version>2.3.6.RELEASE</security.oauth.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!--Lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!--测试依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!--io管理-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>${spring-platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--稳定版本,替代spring security bom内置-->
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>${security.oauth.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<!--打包工具-->
<build>
<finalName>${project.name}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<target>${maven.compiler.target}</target>
<source>${maven.compiler.source}</source>
<encoding>UTF-8</encoding>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.5</version>
</plugin>
</plugins>
</build>
<!--子项目-->
<modules>
<module>spring-security-app</module>
<module>spring-security-core</module>
<module>spring-security-browser</module>
<module>spring-security-demo</module>
</modules>
<repositories>
<!--阿里云代理-->
<repository>
<id>aliyun</id>
<name>aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>
</repositories>
</project>
spring-security-core项目pom依赖
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.spring.security</groupId>
<artifactId>spring-security</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>spring-security-core</artifactId>
<packaging>jar</packaging>
<description>核心业务逻辑</description>
<dependencies>
<!--安全模块 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--第三方登录-->
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-web</artifactId>
</dependency>
<!--工具包-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!--server-api-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
</dependencies>
</project>
spring-security-browser项目pom依赖
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.spring.security</groupId>
<artifactId>spring-security</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>spring-security-browser</artifactId>
<packaging>jar</packaging>
<description>浏览器安全特定代码</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.spring.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.security}</version>
</dependency>
</dependencies>
</project>
spring-security-app项目pom依赖
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.spring.security</groupId>
<artifactId>spring-security</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>spring-security-app</artifactId>
<packaging>jar</packaging>
<description>APP相关特定代码</description>
<dependencies>
<dependency>
<groupId>com.spring.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.security}</version>
</dependency>
</dependencies>
</project>
spring-security-demo项目pom依赖
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.spring.security</groupId>
<artifactId>spring-security</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>spring-security-demo</artifactId>
<packaging>jar</packaging>
<description>样例程序</description>
<dependencies>
<dependency>
<groupId>com.spring.security</groupId>
<artifactId>spring-security-browser</artifactId>
<version>${spring.security}</version>
</dependency>
<!--web 模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!--打包-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
以上是 【SpringSecurity+OAuth2+JWT入门到实战】1.项目介绍和创建 的全部内容, 来源链接: utcz.com/z/513987.html