zoukankan      html  css  js  c++  java
  • springBoot总结

    springBoot总结:

    ssm基本的依赖:

    <dependencies>
            <!--添加依赖thymeleaf 可以访问html页面-->
            <!--<dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
            </dependency>-->
            <!--对jsp访问的支持-->
            <dependency>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-jasper</artifactId>
                <!--<scope>provided</scope>-->
            </dependency>
            <!--独立发布到tomcat-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <scope>provided</scope>
            </dependency>
              <!--热部署依赖-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
            </dependency>
            <!--    spring boot的web支持-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <!--mybatis-spring桥梁-->
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>1.1.1</version>
            </dependency>
            <!--mysql驱动包-->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <scope>runtime</scope>
            </dependency>
            <!--aop-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-aop</artifactId>
            </dependency>
            <!--jdbc-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
    View Code

    模板引擎:

    1:jsp:

    依赖:

        <!--对jsp访问的支持-->
            <dependency>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-jasper</artifactId>
            </dependency>

    controller层页面跳转:

     2:html页面的支持:(需要 thymeleaf  jar包)

    依赖:

     <!--模板引擎thmeleaf对HTML的支持-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
            </dependency>

    controller层页面跳转:

     3、springBoot在idea中如何热部署(即启动项目后,修改方法内部或静态页面不需要重启):

      1.热部署的Maven依赖:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>
    2. Alt+Ctrl+Shift+/ :设置

     

     3:找到Settings的 compiler项,勾选Build project automatically 

     4:springBoot项目如何打成war包 发布:

    1.将spring-boot-starter-tomcat的范围设置为provided

    设置为provided是在打包时会将该包排除,因为要放到独立的tomcat中运行,是不需要的。

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <scope>provided</scope>
            </dependency>

    2.修改启动类:

    继承 springBootServletInitializer 类 重写 configure方法:

    3:打包:

     

    打包完之后在项目保存的文件夹找到target包中的war包复制到tomcat中即可。

  • 相关阅读:
    Windows 常见错误总结
    Windows 常用快捷方式
    【Linux】wget: command not found的两种解决方法
    【Linux】VirtualBox虚拟网络配置
    【Linux】启动Tomcat遇到Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
    【REDIS】 redis-cli 命令
    【Charles】使用Charles时,抓不到包的情况。
    【Gradle】Downloading https://services.gradle.org/distributions/gradle-3.3-bin.zip 失败
    【LINUX】SHELL syntax error:unexpected end of file
    motan源码分析七:序列化
  • 原文地址:https://www.cnblogs.com/dw3306/p/9779431.html
Copyright © 2011-2022 走看看