标签:占用 apach stl free start ram 排除 com utf-8
这个问题我掉坑里好久,通过启动类启动项目,访问接口正常,访问jsp就是不行。百度了一些方法也没有解决,最后通过命令mvn spring-boot:run启动后访问就正常了。
1,pom文件配置,避免一些坑,我就都引了
<!--jsp支持-->
<!-- servlet 依赖. -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope><!-- 打包时排除springboot内置Tomcat -->
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<!-- tomcat 的支持.-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jsp-api</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<!-- 视图解析 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
<!--<scope>provided</scope>--><!-- 作用域,provided的意思是打包成war包的时候忽略这几个包,因为tomcat会跟这几个包冲突-->
然后在plugins标签里加入,解决控制打印中文乱码
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- spring-boot:run 中文乱码解决 -->
<configuration>
<fork>false</fork><!-- 这里设置为true,就有端口占用问题,设置为false,热部署又有问题,太难了 -->
<!--增加jvm参数-->
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
</configuration>
</plugin>
2,application.yml配置文件
#jsp支持 spring: mvc: view: prefix: /view/ suffix: .jsp
3,点击idea左边的 maven projects,找到spring-boot:run ,右键点击启动,


标签:占用 apach stl free start ram 排除 com utf-8
原文地址:https://www.cnblogs.com/ljmm/p/12768868.html