springboot工程发布到jetty总结

一、中文字符乱码

1、修改webdefault.xml文件zh编码为utf-8

<locale-encoding-mapping>
      <locale>zh</locale>
      <encoding>UTF-8</encoding>
    </locale-encoding-mapping>

2、在application.properties文件增加http编码配置

spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true 

二、启动错误java.lang.RuntimeException: Error scanning entry module-info.class from jar ...

详细错误:

2018-07-17 08:08:15.981:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@34b7bfc0{/mp_store,file:/usr/local/jetty-9.2.25/webapps/mp_store/,STARTING}{/mp_store}
java.lang.RuntimeException: Error scanning entry module-info.class from jar file:/usr/local/jetty-9.2.25/webapps/mp_store/WEB-INF/lib/asm-all-repackaged-2.5.0-b32.jar
    at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:913)
    at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:831)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:164)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:549)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    at java.lang.Thread.run(Thread.java:748)
Caused by: 
java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:973)
    at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:956)
    at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:909)
    at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:831)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:164)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:549)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    at java.lang.Thread.run(Thread.java:748)

原因是asm-all-repackaged-2.5.0-b32.jar编译的jdk9,而服务器我配置的是jdk8,因此降低asm-all-repackaged版本,

<dependency>
   <groupId>org.glassfish.hk2.external</groupId>
   <artifactId>asm-all-repackaged</artifactId>
   <version>2.4.0</version>
</dependency>

三、配置contextPath

在webapps目录,默认以war包的名字作为contextPath。比如war包名为test.war,那么contextPath就为test。当然如果war包是root.war,那么contextPath为“/”。

另外可以在webapps目录增加war包名对应的xml文件实现配置与war包名不同的contextPath。如war包为test.war,则对应增加test.xml文件,内容如下:

<?xml version="1.0"  encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> 
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/test1</Set>
    <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test.war</Set>
</Configure>
这样就设置contextPath为test1了。对应的url就为http://localhost:8080/test1

四、修改jetty端口

jetty9修改端口方法:

修改start.ini文件的jetty.port的值即可

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值