baidu_37483729
weclud
2019-10-17 13:20

springboot证书配置问题

srping boot项目配置完证书后,idea中启动正常,打包成jar后用java -jar 运行报如下错误

11:12:04.641 [main] ERROR o.a.c.u.LifecycleBase - [log,175] - Failed to start co
mponent [Connector[HTTP/1.1-443]]
org.apache.catalina.LifecycleException: Protocol handler start failed
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:
1008)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardService.addConnector(StandardService
.java:227)
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPrevi
ouslyRemovedConnectors(TomcatWebServer.java:263)
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(To
mcatWebServer.java:195)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicat
ionContext.startWebServer(ServletWebServerApplicationContext.java:297)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicat
ionContext.finishRefresh(ServletWebServerApplicationContext.java:163)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:552)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicat
ionContext.refresh(ServletWebServerApplicationContext.java:141)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.
java:744)
        at org.springframework.boot.SpringApplication.refreshContext(SpringAppli
cation.java:391)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java
:312)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java
:1215)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java
:1204)
        at com.weclud.WebApplication.main(WebApplication.java:21)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner
.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
        at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLau
ncher.java:578)
Caused by: java.lang.IllegalArgumentException: Stream closed
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(Abst
ractJsseEndpoint.java:99)
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(Abstrac
tJsseEndpoint.java:71)
        at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:218)
        at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractE
ndpoint.java:1124)
        at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.ja
va:1210)
        at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:585)
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:
1005)
        ... 22 common frames omitted
Caused by: java.io.IOException: Stream closed
        at java.util.zip.InflaterInputStream.ensureOpen(InflaterInputStream.java
:67)
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:142)
        at org.springframework.boot.loader.jar.ZipInflaterInputStream.read(ZipIn
flaterInputStream.java:52)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
        at java.security.DigestInputStream.read(DigestInputStream.java:124)
        at java.io.DataInputStream.readInt(DataInputStream.java:387)
        at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:653)
        at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:5
6)
        at sun.security.provider.KeyStoreDelegator.engineLoad(KeyStoreDelegator.
java:224)
        at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(JavaKeySt
ore.java:70)
        at java.security.KeyStore.load(KeyStore.java:1445)
        at org.apache.tomcat.util.security.KeyStoreUtil.load(KeyStoreUtil.java:6
9)
        at org.apache.tomcat.util.net.SSLUtilBase.getStore(SSLUtilBase.java:217)

        at org.apache.tomcat.util.net.SSLHostConfigCertificate.getCertificateKey
store(SSLHostConfigCertificate.java:206)
        at org.apache.tomcat.util.net.SSLUtilBase.getKeyManagers(SSLUtilBase.jav
a:283)
        at org.apache.tomcat.util.net.SSLUtilBase.createSSLContext(SSLUtilBase.j
ava:247)
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(Abst
ractJsseEndpoint.java:97)
        ... 28 common frames omitted

这是相关配置

# 项目相关配置
weclud:
  # 名称
  name: 文件管理
  # 版本
  version: 1.0
  # 版权年份
  copyrightYear: 2019
  # 获取ip地址开关
  addressEnabled: true

# 开发环境配置
server:
  # 服务端口
  port: 443
  servlet:
    # 项目contextPath
    context-path:
  tomcat:
    # tomcat的URI编码
    uri-encoding: UTF-8
    # tomcat最大线程数,默认为200
    max-threads: 800
    # Tomcat启动初始化的线程数,默认值25
    min-spare-threads: 30

  ssl:
    key-store: classpath:static/dacx.weclud.com.jks
    key-store-password: zhang1990
    key-store-type: jks

<build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**.*</include>
                    <include>**/*.*</include><!-- i18n能读取到 -->
                    <include>**/*/*.*</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <excludes>
                    <exclude>ssl/**</exclude>
                    <exclude>static/**</exclude>
                    <exclude>templates/**</exclude>
                </excludes>
            </resource>
        </resources>

        <!-- 为jar包取名 -->
        <finalName>weclud-web</finalName>
        <plugins>
            <!-- 热布署 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <!--fork :  如果没有该项配置,这个devtools不会起作用,即应用不会restart -->
                    <fork>true</fork>
                    <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
                    <mainClass>com.weclud.WebApplication</mainClass>
<!--                    <layout>ZIP</layout>-->
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
                        </goals>
                        <!--可以生成不含依赖包的不可执行Jar包-->
                        <!-- configuration>
                          <classifier>exec</classifier>
                        </configuration> -->
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

相关推荐