jdk8 升级 jdk17 docker 部署失败
首先,感谢 http://www.manongjc.com/detail/42-hiwfjklnbpukjgd.html & https://huaweicloud.csdn.net/654a1218525bff6100e99afd.html
在jdk8 升级 jdk17,项目 docker 部署失败。报错:
### SQL: SELECT id, wechat_nick_name, open_id, name, take_effect, mobile, email, username, introduce, wechat_avatar, team_dept_id, create_user, create_time, update_user, update_time, is_deleted, hire_date, resignation_date, hire_enable, employment_length, honor, is_agent FROM team_user WHERE (open_id = ?) ### Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @2be94b0f at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) ~[mybatis-3.5.13.jar!/:3.5.13] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:156) ~[mybatis-3.5.13.jar!/:3.5.13] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) ~[mybatis-3.5.13.jar!/:3.5.13] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:142) ~[mybatis-3.5.13.jar!/:3.5.13] at jdk.internal.reflect.GeneratedMethodAccessor40.invoke(Unknown Source) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425) ~[mybatis-spring-2.1.1.jar!/:2.1.1] ... 112 common frames omitted
1. 帮助我找到问题原因之一:--add-opens=java.base/java.lang=ALL-UNNAMED 在 docker 部署时必须这么写。
oracle 官方说 vm-optins 需要设置成 --add-opens java.base/java.lang=ALL-UNNAMED,但是这么写在 docker 不认。
标准写法是:
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Duser.timezone=Asia/Shanghai","--add-opens=java.base/java.lang=ALL-UNNAMED","--add-opens=java.base/java.lang.reflect=ALL-UNNAMED","--add-opens=java.base/java.io=ALL-UNNAMED","--add-opens=java.base/java.util=ALL-UNNAMED","-jar","app.jar"]
2. Dockerfile 里面不能有换行
因为太长,我把 ENTRYPOINT 数组按逗号换行了。但事实是 jenkins 日志显示 docker 不认。只读取到了第一行。