我厌倦了调查这个问题,也找不到合适的答案。实际上,我没有发现任何人使用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发布和BOM编写的。该应用程序以前在此路径下有一个get控制器:“/login”。这里有一个棘手的部分:每当你点击URL时”
https://www.myapp.com/login.htm
“,在某种程度上/某种程度上,我不理解,Spring管理它将”login.htm“的请求发送到控制器”/登录。我不知道它是如何认识到额外的“.htm”的。
现在,当我使用Java 11和Spring 2.1.0.Effice时,这已经不起作用了。如果我点击“/login”,它会转到控制器。但是我需要做一个透明的迁移,我不能改变逻辑。这个应用程序为请求提供服务,客户端从几年前就开始使用“/login.htm”。我需要设置“/login.htm”转到“/login”。