最近在学Spring微服务,用的书是Carnell的 Spring Micro-service in Action
小插曲
在构建代码时,
示例代码用的是jdk8,而我的是jdk13
在jdk13中(自从jdk11)去除了javax.activation库
于是报了找不到DataSource类的错,更换jdk8解决
关于JCE
执行
mvn clean package docker:build
后,出现问题
在dockerFile的脚本执行过程中
unzip:short read
StackOverflow上的解释
“short read” means that the read() syscall was invoked, but less information than requested was returned. Now, that can happen completely legitimately, and software that doesn’t do another read() call to try to get more content (which the standard C library will automate) is buggy, but as an initial question – is your file really intact and as long as it should be?
大概意思是,unzip程序用UNIX system call read()的时候,没有读到unzip预期的长度,即文件长度与读取到长度不同,就会报这个错误
在Oracle网站下载JCE文件时,下载不全,导致unzip报错
解决
这是Oracle的下载节点问题,因为书的示例代码在两年前,Oracle节点那也相应做出了协议同意选项的调整,因此采用新的Dockerfile脚本
FROM openjdk:8-jdk-alpine
RUN apk update && apk upgrade && apk add netcat-openbsd && apk add curl
RUN mkdir -p /usr/local/configserver
RUN cd /tmp/ && \
curl -L -b "oraclelicense=a" http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip -O** && \
unzip jce_policy-8.zip && \
rm jce_policy-8.zip && \
yes |cp -v /tmp/UnlimitedJCEPolicyJDK8/*.jar /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/
ADD @project.build.finalName@.jar /usr/local/configserver/
ADD run.sh run.sh
RUN chmod +x run.sh
CMD ./run.sh
亲测可用