栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot + SpringSecurity 环境搭建的步骤

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot + SpringSecurity 环境搭建的步骤

一、使用SpringBoot+Maven搭建一个多模块项目(可以参考这篇文章 --> 这里)

二、删除父工程的src文件,删除app、browser、core下的.java文件

依赖关系:

  1. demo 依赖 browser
  2. browser、app依赖core

三、父工程pom.xml文件

 
 
  4.0.0 
 
  com.zeke 
  zeke-security 
  0.0.1-SNAPSHOT 
  pom 
  zeke-security 
 
   
    1.0-SNAPSHOT 
   
 
   
    zeke-security-app 
    zeke-security-browser 
    zeke-security-core 
    zeke-security-demo 
   
 
   
     
      junit 
      junit 
      test 
     
     
      org.springframework.boot 
      spring-boot-test 
      1.5.8.RELEASE 
      test 
     
   
 
   
     
       
 io.spring.platform 
 platform-bom 
 Brussels-SR6 
 pom 
 import 
       
       
 org.springframework.cloud 
 spring-cloud-dependencies 
 Dalston.SR5 
 pom 
 import 
       
       
 org.springframework.boot 
 spring-boot-configuration-processor 
 true 
       
     
   
 
   
     
       
 org.apache.maven.plugins 
 maven-compiler-plugin 
 2.3.2 
  
   1.8 
   1.8 
   UTF-8 
  
       
     
   
 
 

四、zeke-security-demo项目下的pom.xml文件 

 
 
  4.0.0 
 
   
    com.zeke 
    zeke-security 
    0.0.1-SNAPSHOT 
   
 
  zeke-security-demo> 
 
   
     
      com.zeke 
      zeke-security-browser 
      ${zeke-security-version} 
     
     
      junit 
      junit 
      4.12-beta-3 
      test 
     
     
      org.springframework.boot 
      spring-boot-starter-aop 
     
     
      commons-io 
      commons-io 
     
 
     
     
      io.springfox 
      springfox-swagger2 
      2.7.0 
     
     
      io.springfox 
      springfox-swagger-ui 
      2.7.0 
     
 
     
     
      com.github.tomakehurst 
      wiremock 
      2.14.0 
     
     
      org.springframework 
      spring-test 
      4.3.12.RELEASE 
      test 
     
     
      org.springframework 
      spring-test 
      4.3.12.RELEASE 
      test 
     
     
      org.springframework 
      spring-test 
      4.3.12.RELEASE 
      test 
     
   
 
   
     
       
 org.springframework.boot 
 spring-boot-maven-plugin 
 1.5.6.RELEASE 
  
    
      
repackage 
      
    
  
       
     
    demo 
   
 

五、zeke-security-core项目下的pom.xml文件 

 
 
  4.0.0 
 
   
    zeke-security 
    com.zeke 
    0.0.1-SNAPSHOT 
   
 
  zeke-security-core 
 
   
     
      org.springframework.cloud 
      spring-cloud-starter-oauth2 
     
     
     
     
     
     
      org.springframework.boot 
      spring-boot-starter-jdbc 
     
     
      mysql 
      mysql-connector-java 
     
     
      org.springframework.social 
      spring-social-config 
     
     
      org.springframework.social 
      spring-social-core 
     
     
      org.springframework.social 
      spring-social-security 
     
     
      org.springframework.social 
      spring-social-web 
     
     
      commons-lang 
      commons-lang 
     
     
      commons-collections 
      commons-collections 
     
     
      commons-beanutils 
      commons-beanutils 
     
   
 

六、zeke-security-browser项目下的pom.xml文件 

 
 
  4.0.0 
 
   
    com.zeke 
    zeke-security 
    0.0.1-SNAPSHOT 
   
 
  zeke-security-browser 
 
   
     
      com.zeke 
      zeke-security-core 
      ${zeke-security-version} 
     
     
      org.springframework.session 
      spring-session 
     
   
 

七、zeke-security-app项目下的pom.xml文件 

 
 
  4.0.0 
 
   
    zeke-security 
    com.zeke 
    0.0.1-SNAPSHOT 
   
 
  zeke-security-app 
 
   
     
      com.zeke 
      zeke-security-core 
      ${zeke-security-version} 
     
   
 

八、zeke-security-demo项目下的application.properties

 spring.datasource.driver-class-name=com.mysql.jdbc.Driver 
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/imooc-demo 
spring.datasource.username=root 
spring.datasource.password= 
 
spring.session.store-type=none 
security.basic.enabled=false 

九、在zeke-security-demo启动类上添加测试接口

@RestController 
@SpringBootApplication 
public class ZekeSecurityDemoApplication { 
 
  public static void main(String[] args) { 
    SpringApplication.run(ZekeSecurityDemoApplication.class, args); 
  } 
 
  @GetMapping("/hello") 
  public String hello(){ 
    return "success"; 
  } 
} 

十、输入地址localhost/hello

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/140790.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号