zoukankan      html  css  js  c++  java
  • springboot的常见配置

    1.Springboot热部署

    热部署的意思就是当任何类发生改变时,通过JVM类加载的方式加载到虚拟机上,这样就不需要我们重启Application类了

    做法:

    1)添加一个依赖到pom.xml上:
         <!--热部署-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
                <optional>true</optional>
            </dependency>

    另外确保存在以下插件

               <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
              </plugin>   

    2)File-Setting-compiler-勾上Build project automatically

    快捷键ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running

     当我们修改类的时候就可以看到控制台自动重启

    2.修改访问的端口号和上下文路径

    server.port=8087
    server.servlet.context-path=/springboot

     3.JSP视图

    1)添加如下依赖

         <!-- servlet依赖-->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
    
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
            </dependency>
    
            <!--Tomcat依赖-->
            <dependency>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-jasper</artifactId>
            </dependency>

    2)在application.propertie里增加

    写一个类测试

    在main目录下新增webapp/WEB-INF/jsp 目录,新建currentTime.jsp

    效果为:

     4.多配置文件的切换

    3个配置文件:
    核心配置文件:application.properties
    开发环境用的配置文件:application-dev.properties
    生产环境用的配置文件:application-pro.properties

    比如我这里开发用8087的端口和test的路径

    使用thymeleaf模板时就用8086和thymeleaf的路径

     

     
  • 相关阅读:
    模拟
    广搜——最优方案
    动态规划——背包
    动态规划——树规
    动态规划——区间
    fill 的用法
    状态压缩dp
    超大背包问题
    lower_bound
    弹性碰撞 poj 3684
  • 原文地址:https://www.cnblogs.com/wutongshu-master/p/10867458.html
Copyright © 2011-2022 走看看