springboot集成jsp,可以打包
2017-11-02 10:01
531 查看
1、创建MAVEN工程
2、pom.xml配置
设置parent标签 版本必须为1.4系列,否则可能无法打包
设置所有依赖,可以根据需求增加
build标签
3、配置application.properties
创建application.properties文件,路径src/main/resources下
4、jsp路径
创建资源路径src/main/webapp
在此资源路径下创建folder 两级目录/WEB-INF/jsp/
folder: src/main/webapp/WEB-INF/jsp/xxx.jsp
src/main/webapp/WEB-INF/xxx.jsp
2、pom.xml配置
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.8</java.version> <main.basedir>${basedir}/../..</main.basedir> <m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot> </properties>
设置parent标签 版本必须为1.4系列,否则可能无法打包
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.2.RELEASE</version> </parent>
设置所有依赖,可以根据需求增加
<dependencies> <!-- springboot启动包 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- jsp相关依赖 --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> <!-- tomcat支持 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId 4000 >tomcat-embed-jasper</artifactId> </dependency> <!-- 单元测试 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> <!-- 添加devtools依赖,用于热部署 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <scope>true</scope> </dependency> </dependencies>
build标签
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!-- fork: 如果没有该配置,devtools不会起作用 --> <fork>true</fork> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> <resources> <!-- 打包时将jsp文件拷贝到META-INF目录下 --> <resource> <!-- 指定resources插件处理哪个目录下的资源文件 --> <directory>src/main/webapp</directory> <!--注意此次必须要放在此目录下才能被访问到 --> <targetPath>META-INF/resources</targetPath> <includes> <include>**/**</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/**</include> </includes> <filtering>false</filtering> </resource> </resources> </build>
3、配置application.properties
创建application.properties文件,路径src/main/resources下
spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp
4、jsp路径
创建资源路径src/main/webapp
在此资源路径下创建folder 两级目录/WEB-INF/jsp/
folder: src/main/webapp/WEB-INF/jsp/xxx.jsp
src/main/webapp/WEB-INF/xxx.jsp
相关文章推荐
- IntelliJ IDEA Spring Boot(8)使用JSP,打包jar文件运行带有jsp的项目
- 将消息中心改造成springboot项目,并集成maven打包docker image
- 杨品的文档之--spring-boot集成jsp配置
- SpringBoot打包成jar在服务器上无法访问JSP页面问题
- 使用IDEA在Spring Boot中集成JSP
- spring-boot集成 jsp报whitelabel error page的问题解决
- 81. Spring Boot集成JSP疑问【从零开始学Spring Boot】
- Spring Boot 集成JSP
- Spring Boot gradle 集成servlet/jsp 教程及示例
- SpringBoot集成jsp
- Spring-boot集成JSP
- Spring Boot 集成servlet,发布为可直接运行的war包,方便后续打包为docker镜像。
- 使用IDEA在Spring Boot中集成JSP
- Spring Boot项目与Docker集成完成打包,打镜像及推送至镜像库的功能
- eclipse中使用spring boot 入门开发(包含:与jsp页面和数据库交互,cmd打包运行war包)
- Spring Boot 最佳实践(二)集成Jsp与生产环境部署
- 从零学springboot—— springboot集成jsp
- 使用IDEA在Spring Boot上集成JSP
- SpringBoot入门之集成JSP的示例代码
- spring boot 集成jsp