zoukankan      html  css  js  c++  java
  • springboot常见写法

    访问html文件

    对于aa.html页面,采用跳转到方式:放在templates目录下时,要加一个thymeleaf依赖,并在controller跳转。

    不用跳转到方式: 将依赖去掉,将controler去掉,直接放在static目录下

    采用devtools进行热部署

    热部署指的是springboot在启动后,默认监听classpath路径下的.class文件

    不被热部署的文件:    META-INF/maven/     META-INF/resources /            /resources         /static            /public       /templates

    可以设置一个触发器,只有某个文件发生改变时,才重启进行热部署

    读取配置文件注入到属性

    第一种情况

    1  配置文件 : application.properties

    test.domain=www.xxx.net
    test.name=springboot

     2 一个普通的java类

    @Component
    @PropertySource({"classpath:application.properties"})
    @ConfigurationProperties(prefix="test")
    public class ServerSettings {

    //名称
    private String name;

    private String domain;

    }

    3  其他的controller类注入bean

    @Autowired
    private ServerSettings serverSettings;

    第二种情况

    1  配置文件 : application.properties

    web.file.path=/Users/xxxxx/Desktop/

    2 在controller类中

    @Controller
    @PropertySource({"classpath:application.properties"})
    public class FileController { 

         @Value("${web.file.path}")
          private String filePath;

    }

  • 相关阅读:
    Bundle类
    intent.putExtra()方法参数详解
    6级技巧(一)
    6级核心词汇
    安卓应用运营知识:VersionCode和VersionName
    关于HTML、XHTML、CSS、XML的区别
    SQL记录-Linux CentOS配置ORACLE 12c
    Spark记录-Scala多线程
    Spark记录-Scala异常与处理
    Spark记录-Scala类和对象
  • 原文地址:https://www.cnblogs.com/moris5013/p/9943741.html
Copyright © 2011-2022 走看看