SpringSecurity 框架学习 项目创建
Maven 项目创建父工程 pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | < 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.imooc.security</ groupId > < artifactId >imooc-security</ artifactId > < version >1.0.0-SNAPSHOT</ version > < packaging >pom</ packaging > <!--定义版本变量--> < properties > < imooc.security.version >1.0.0-SNAPSHOT</ imooc.security.version > </ properties > <!--由spring platform 来管理版本依赖版本--> < dependencyManagement > < dependencies > < dependency > < groupId >io.spring.platform</ groupId > < artifactId >platform-bom</ artifactId > < version >Brussels-SR4</ version > < type >pom</ type > < scope >import</ scope > </ dependency > < dependency > < groupId >org.springframework.cloud</ groupId > < artifactId >spring-cloud-dependencies</ artifactId > < version >Dalston.SR2</ version > < type >pom</ type > < scope >import</ scope > </ dependency > </ dependencies > </ dependencyManagement > <!--编译java版本--> < build > < plugins > < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-compiler-plugin</ artifactId > < version >2.3.2</ version > < configuration > < source >1.8</ source > < target >1.8</ target > < encoding >UTF-8</ encoding > </ configuration > </ plugin > </ plugins > </ build > <!--子模块依赖--> < modules > < module >../imooc-security-app</ module > < module >../imooc-security-browser</ module > < module >../imooc-security-core</ module > < module >../imooc-security-demo</ module > </ modules > </ project > |
子模块 security-core pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | < 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 > < artifactId >imooc-security-core</ artifactId > < parent > < groupId >com.imooc.security</ groupId > < artifactId >imooc-security</ artifactId > < version >1.0.0-SNAPSHOT</ version > < relativePath >../imooc-security</ relativePath > </ parent > < 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 >commons-lang</ groupId > < artifactId >commons-lang</ artifactId > </ dependency > < dependency > < groupId >commons-collections</ groupId > < artifactId >commons-collections</ artifactId > </ dependency > < dependency > < groupId >commons-beanutils</ groupId > < artifactId >commons-beanutils</ artifactId > </ dependency > < dependency > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-configuration-processor</ artifactId > </ dependency > </ dependencies > </ project > |
子模块 security-browser pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | < 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 > < artifactId >imooc-security-browser</ artifactId > < parent > < groupId >com.imooc.security</ groupId > < artifactId >imooc-security</ artifactId > < version >1.0.0-SNAPSHOT</ version > < relativePath >../imooc-security</ relativePath > </ parent > < dependencies > < dependency > < groupId >com.imooc.security</ groupId > < artifactId >imooc-security-core</ artifactId > < version >${imooc.security.version}</ version > </ dependency > < dependency > < groupId >org.springframework.session</ groupId > < artifactId >spring-session</ artifactId > </ dependency > < dependency > < groupId >org.apache.shiro</ groupId > < artifactId >shiro-core</ artifactId > < version >1.2.2</ version > </ dependency > </ dependencies > </ project > |
子模块 security-app pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | < 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 > < artifactId >imooc-security-app</ artifactId > < parent > < groupId >com.imooc.security</ groupId > < artifactId >imooc-security</ artifactId > < version >1.0.0-SNAPSHOT</ version > < relativePath >../imooc-security</ relativePath > </ parent > < dependencies > < dependency > < groupId >com.imooc.security</ groupId > < artifactId >imooc-security-core</ artifactId > < version >${imooc.security.version}</ version > </ dependency > </ dependencies > </ project > |
子模块 security-demo pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | < 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 > < artifactId >imooc-security-demo</ artifactId > < parent > < groupId >com.imooc.security</ groupId > < artifactId >imooc-security</ artifactId > < version >1.0.0-SNAPSHOT</ version > < relativePath >../imooc-security</ relativePath > </ parent > < dependencies > < dependency > < groupId >com.imooc.security</ groupId > < artifactId >imooc-security-browser</ artifactId > < version >${imooc.security.version}</ version > </ dependency > < dependency > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-starter-test</ artifactId > </ dependency > < dependency > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-starter-aop</ artifactId > </ dependency > < dependency > < groupId >commons-io</ groupId > < artifactId >commons-io</ artifactId > </ dependency > < dependency > < groupId >io.springfox</ groupId > < artifactId >springfox-swagger2</ artifactId > < version >2.7.0</ version > </ dependency > < dependency > < groupId >io.springfox</ groupId > < artifactId >springfox-swagger-ui</ artifactId > < version >2.7.0</ version > </ dependency > < dependency > < groupId >com.github.tomakehurst</ groupId > < artifactId >wiremock</ artifactId > </ dependency > </ dependencies > <!--打包插件,打包完整的可执行jar --> < build > < plugins > < plugin > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-maven-plugin</ artifactId > < version >1.3.3.RELEASE</ version > < executions > < execution > < goals > < goal >repackage</ goal > </ goals > </ execution > </ executions > </ plugin > </ plugins > < finalName >demo</ finalName > </ build > </ project > |
项目目录结构
在demo中编写测试 类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | package com.imooc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; /** * @Title: DemoApplication * @ProjectName imooc-security * @date 2020/11/2710:20 */ @RestController @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication. class , args); } @GetMapping ( "/hello" ) public String hello() { return "hello spring security" ; } } |
application.yml
1 2 3 4 5 6 7 8 9 10 11 12 | spring: datasource: driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql: //127 .0.0.1:3306 /imooc-demo ?useUnicode= yes &characterEncoding=UTF-8&useSSL= false username: root password: 412013 session: store- type : none security: basic: enabled: false |
至此项目创建完成
标签:
SpringBoot
, Spring Cloud
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
2018-11-27 tmux