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>
模板引擎:
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中即可。