• Springboot


    1.静态资源引入-------   存放查找路径:

    spring.mvc.static-path-pattern=/**

    spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/, classpath:/static/,classpath:/public/
    2.配置文件引入:

    yaml   注解: @ConfigurationProperties(prefix="xxx")

    properties    注解:@PropertySource(value="相对路径") @Value("${xx}")

    注:配置插件 springassist  提示yaml 和properties 配置文件的提示信息

    3.添加@Transactional  @Slf4j的用法  service 层 和 controller 打印日志

    4.thymeleaf 页面

    模板替换 :模板页面header.html    <header th:replace="header::html></header> 替换header标签调用header.html

    <link rel="stylesheet" th:href="@{/.../font.css}">  /代表/static/ 目录    @{}加双引号

    thymeleaf 扩展shiro支持:
    
    1.<dependency>
        <groupId>com.github.theborakompanioni</groupId>
        <artifactId>thymeleaf-extras-shiro</artifactId>
        <version>2.0.0</version>
    </dependency>
    2.配置shirodialect 对象。在shiroConfig中
    3.增加shiro:hasPermssion="roles"标签属性。

    5.shiro-springboot的配置流程

    1.导入springboot支持的shiro包 
    shiro-spring-boot-web-starter
    2.配置shiroConfiger类
        1.配置shiroFilterFactoryBean类
        2.配置DefaultShirowebSecurityManager类
        3.配置继承AutorizaingRealm抽象类的自定义类UserRealm并实现
         doGetAuthorizationInfo  
        授权需要注意:Subject subject = SecurityUtils.getSubject();
        subject.getprincipal()
    simpleAuthorizationInfo.addStringPermission(user.getPerms());
    doGetAuthenticationInfo 方法
          获取token  包含前端传递的username和password
    new SimpleAuthenticationInfo(user,user.getPassword(),"")
      controller里:
    Subject subject = SecurityUtils.getSubject();
     UsernamePasswordToken token = new UsernamePasswordToken(username, password);
    
        4.还可以配置ShiroDialect类
    
    
  • 相关阅读:
    java通过LinkedList实现堆栈和队列数据结构
    华硕笔记本无法调节屏幕亮度
    Java8新特性
    GitLab使用记录
    Java IO流关闭问题之原理简析
    gradle build docker image
    mysql安装及使用
    前端div层级控制
    Could not get dialect instance.
    Starting a Gradle Daemon, 5 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details FAILURE: Build failed with an exception. * What went wrong: Could not dispatch
  • 原文地址:https://www.cnblogs.com/chencn/p/12410819.html
Copyright © 2020-2023  润新知