最新spring boot搭建,整合jsp页面以及打war包配置
2017-08-08 23:52
866 查看
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>SpringBootDemo</groupId>
<artifactId>SpringBootDemo</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Spring-Cloud Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<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-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<finalName>Spring-Cloud</finalName>
</build>
</project>
application.yml:
spring.mvc.view.prefix: /jsp/
spring.mvc.view.suffix: .jsp
application.message: Hello
source 结构:
注意start类的位置
Start.java:
package spring.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
@SpringBootApplication
public class Start extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Start.class);
}
public static void main(String[] args) {
SpringApplication.run(Start.class, args);
}
}
HelloController.java
package spring.boot.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "index";
}
}
附上成功截图:
部署tomcat后:
我还记得当初学习springboot的时候看网上的文章教程。。。整合jsp加了一堆依赖,打war包还有人出各种方案。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>SpringBootDemo</groupId>
<artifactId>SpringBootDemo</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Spring-Cloud Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<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-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<finalName>Spring-Cloud</finalName>
</build>
</project>
application.yml:
spring.mvc.view.prefix: /jsp/
spring.mvc.view.suffix: .jsp
application.message: Hello
source 结构:
注意start类的位置
Start.java:
package spring.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
@SpringBootApplication
public class Start extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Start.class);
}
public static void main(String[] args) {
SpringApplication.run(Start.class, args);
}
}
HelloController.java
package spring.boot.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "index";
}
}
附上成功截图:
部署tomcat后:
我还记得当初学习springboot的时候看网上的文章教程。。。整合jsp加了一堆依赖,打war包还有人出各种方案。
相关文章推荐
- 快速搭建springboot框架以及整合ssm+shiro+安装Rabbitmq和Erlang、Mysql下载与配置
- 关于Spring Boot WebSocket整合以及nginx配置详解
- springboot-10-前端页面整合, thymeleaf, freemarker, jsp 模板使用
- thymeleaf :springboot整合mybatis的web项目中使用html而不是jsp当页面渲染
- spring boot整合jsp及设置启动页面的方法
- SpringBoot整合MyBatis(包含热部署及其JSP配置详解)
- 配置springboot jsp页面跳转
- springboot微服务搭建(一):整合mybatis配置(第一种方式)
- springboot学习笔记-2 一些常用的配置以及整合mybatis
- drools 整合SpringBoot在IDEA上的设置以及gradle配置
- springboot 整合jsp版本war包Tomcat启动不起来
- springboot打包jar包找不到jsp文件以及在linux永久执行java -jar以及springboot的多环境配置
- eclipse中使用spring boot 入门开发(包含:与jsp页面和数据库交互,cmd打包运行war包)
- SpringBoot配置使用jsp页面技术
- spring boot最新教程(三):Spring Boot整合JdbcTemplate以及事务管理
- Spring boot(9) 的异常,以及异常页面的处理
- spring boot / cloud (十七) 快速搭建注册中心和配置中心
- spring boot最新教程(四):返回json数据以及集成fastjson的使用
- 学习cassandra(1)入门,使用场景(写多读少)和搭建启动使用,整合Spring boot
- Spring Boot基本配置和常见的运行时错误以及解决