在Eclipse / STS的Spring Boot中使用嵌入式Tomcat运行Spring MVC

时间:2019-02-04 16:50:16

标签: eclipse spring-boot spring-mvc embedded-tomcat-8

我正在使用STS通过Spring Boot开发Spring MVC项目,但是我无法使用嵌入式Tomcat运行该项目;具体来说,嵌入式Tomcat无法找到要交付的JSP页面。但是,当我在独立的Tomcat中部署它时,我没有问题。这是我在application.properties中拥有的东西:

spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp

这是我放置JSP页面的位置:

src/main/webapp/WEB-INF/jsp/welcome.jsp

这是我的gradle.build的样子:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
group = 'com.hua'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
  maven {
    credentials {
      username "${artifactory_user}"
      password "${artifactory_password}"
    }
    url "${artifactory_contextUrl}"+'/maven_deploy_virtual'
  }
}
dependencies {
  implementation 'org.springframework.boot:spring-boot-starter-web'
  testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

当我尝试使用嵌入式Tomcat运行JSP页面时,我认为很可能需要以某种方式告诉STS在哪里找到JSP页面。但是我不确定该怎么做。有人可以给我一些指导吗?非常感谢!

0 个答案:

没有答案