0

我厌倦了调查这个问题,我找不到合适的答案。实际上,我没有发现任何人使用 Java 11 和 Spring。我的 JSP 没有加载,就是这样。关于我的项目的一些信息:

Spring Boot version: 2.0.5.RELEASE
Java version: 11
Gradle: 4.10.2

这些是我的 application.yml 属性:

server:
  contextPath: /mypath
  port: 9012
  display-name: my app
  error:
    whitelabel:
      enabled: true
  tomcat:
    compression: on
    compressableMimeTypes: application/json,application/xml,text/html,text/xml,text/plain
    # springboot 1.3+ compression
#    compression:
#      enabled: true
#      mime-types: application/json,application/xml,text/html,text/xml,text/plain
    # enable HTTPS when running behind a proxy server
    remote_ip_header: x-forwarded-for
    protocol_header: x-forwarded-proto
  use-forward-headers: true
  # session timeout
  session:
    # spring time out set to 2hrs.
    cookie:
      max-age: 7200
    timeout: 7200
  # enabling SSL/HTTPS with spring boot
  ssl:
    enabled: true
    key-store: /mykeystorepath/keystore.ks
    key-store-password: password
    key-store-type: JKS
    key-alias: selfsigned

http:
  mappers:
    jsonPrettyPrint: true

multipart:
  maxFileSize: 500MB
  maxRequestSize: 500MB
  fileSizeThreshold: 0

spring:
  application:
    name: appname
  jmx:
    enabled: true
    default-domain: ${spring.application.name}
  http:
    # enable and force http encoding support.
    encoding:
      enabled: true
      charset: UTF-8
      force: true
  mvc:
    favicon:
      enabled: true
    view:
      prefix: /WEB-INF/jsp/
      suffix: .jsp

management:
  server:
    port: 9512
  endpoints:
    web:
      base-path: /manage

swagger:
  enable: false

endpoints:
  shutdown:
    enabled: true

#logging:
#  level:
#    org:
#      springframework:
#        web: DEBUG

我的jsp文件在:

/parent-project-folder/my-app/src/main/webapp/WEB-INF/jsp/

我的主要课程:

@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
public class Application extends SpringBootServletInitializer {

    /** The log. */
    private static final Logger LOG = LoggerFactory.getLogger(Application.class);

    /**
     * The main method.
     *
     * @param args the arguments
     */
    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(Application.class);
        springApplication.addListeners(new ApplicationPidFileWriter(System.getProperty("user.home") + File.separator + "app.pid"));
        springApplication.run(args);

        LOG.info("--------------------------------------------------------------");
        LOG.info("--------- application startup complete --------");
        LOG.info("--------------------------------------------------------------");
    }

    /*
     * (non-Javadoc)
     *
     * @see org.springframework.boot.web.support.SpringBootServletInitializer#configure(org.springframework.boot.builder.SpringApplicationBuilder)
     */
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

}

我什至尝试将我的 WEB-INF 文件夹放在 /src/main/resources 下。

接下来,这是我的依赖项列表(只是草稿复制粘贴):

apply plugin: 'war'

    compile 'javax.servlet:jstl:1.2'
classpath 'gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.4.17'
        classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.5"
        classpath "com.netflix.nebula:gradle-ospackage-plugin:4.4.0"
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4"
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
        classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.4"
        classpath 'com.github.samueltbrown:gradle-cucumber-plugin:0.5'

compile 'org.glassfish.corba:glassfish-corba-omgapi:4.2.0-b004'
        compile 'org.jboss.spec.javax.xml.soap:jboss-saaj-api_1.3_spec:1.0.6.Final'
        runtime 'org.springframework.boot:spring-boot-properties-migrator'
        compile 'javax.xml.bind:jaxb-api:2.3.0'
        compile 'com.sun.xml.bind:jaxb-core:2.3.0.1'
        compile 'com.sun.xml.bind:jaxb-impl:2.3.0.1'
        compile 'javax.activation:activation:1.1.1'
        runtime 'javax.activation:javax.activation-api:1.2.0'

        compile 'javax.inject:javax.inject:1'
        compile 'org.apache.commons:commons-lang3:3.7'
        compile "org.springframework.boot:spring-boot-starter-actuator"
        compile "org.springframework.boot:spring-boot-starter-security"
compile (group: 'org.owasp.esapi', name: 'esapi', version:'2.1.0.1') {
                exclude group: 'org.apache.xmlgraphics'
            }

            compile "com.google.code.gson:gson:${gsonVersion}"
            compile 'taglibs:standard:1.1.2'
            compile 'org.apache.tomcat.embed:tomcat-embed-jasper'

            compile 'org.springframework.boot:spring-boot'
            compile "org.springframework.cloud:spring-cloud-starter-config"
            compile "org.springframework.boot:spring-boot-starter-web"
            compile "org.springframework.boot:spring-boot-starter-tomcat"
            compile "org.springframework.boot:spring-boot-starter-logging"
            compile 'com.mangofactory:swagger-springmvc:1.0.2'

            runtime  group: 'ph.samson.logback', name: 'logback-luhn-mask', version:'1.0.1'

            compile 'org.apache.xmlgraphics:batik-css:1.10'
            compile 'commons-beanutils:commons-beanutils-core:1.8.3'
            compile 'commons-fileupload:commons-fileupload:1.3.3'
            compile 'xalan:xalan:2.7.2'
            compile 'commons-httpclient:commons-httpclient:3.1'
            compile 'org.owasp.antisamy:antisamy:1.5.7'

我在根目录下有一个 login.jsp,我应该能够像这样https://localhost:9012/mypath/login.html,它不会加载。

11月23日星期五更新

我正在取得一些进展。我将详细解释我的应用程序。最初,这个应用程序是使用 Java 1.8 和 Spring 1.5.9.RELEASE 和 BOM 编写的,用于我的开发。该应用程序曾经在此路径下有一个 GET 控制器:“/login”。棘手的部分来了:每当您点击网址“ https://www.myapp.com/login.htm ”时,以某种我不明白的方式/某种方式,Spring 设法发送请求“ login.htm”到控制器“/login”。我不确定它是如何实现额外的“.htm”的。

现在,当我使用 Java 11 和 Spring 2.1.0.RELEASE 时,这不再起作用了。如果我点击“/login”,它将进入控制器。但我需要进行透明迁移,我无法更改逻辑。这个应用程序服务于请求,并且客户端从多年前就一直在使用“/login.htm”。我需要让“/login.htm”转到“/login”。

4

1 回答 1

0

看起来您在 tomcat 中运行您的应用程序。所以检查它使用的java版本。如果版本低于应用程序 java 版本,则 tomcat 不会运行它。

于 2018-11-29T15:26:08.890 回答