为什么不直接使用JAVA_TOOL_OPTIONS
env 变量?设置后export LC_ALL=de_DE.UTF-8
(在你的.gitlab-ci.yml
)你可以设置export JAVA_TOOL_OPTIONS="-Duser.language=en"
和享受你的英语错误信息。
关于“-Duser.language”不适用于 derby 的 startNetworkServer:startNetworkServer 是一个执行的脚本(以最简单的形式)java -jar derby.jar
。因此,您不能简单地执行bin/startNetworkServer -Duser.language=en
. 但是如果你看一下startNetworkServer
脚本,你会发现使用了一个环境变量DERBY_OPTS
。所以可能它也可以指定export DERBY_OPTS="-Duser.language=en"
,尽管我没有那样尝试。(正如您的评论所述,事实并非如此)
有效的样本.gitlab-ci.yml
:
main:
image: ubuntu:18.04
script:
- apt-get update && apt-get install --yes language-pack-de wget openjdk-8-jdk maven
- export LC_ALL=de_DE.UTF-8
- export JAVA_TOOL_OPTIONS="-Duser.language=en"
- wget http://www-eu.apache.org/dist//db/derby/db-derby-10.14.2.0/db-derby-10.14.2.0-bin.tar.gz && tar xf db-derby-10.14.2.0-bin.tar.gz
- cd db-derby-10.14.2.0-bin && bin/startNetworkServer &
- mvn --batch-mode install
- java -jar target/derby-embedded-data-source-locale-1.0-SNAPSHOT-jar-with-dependencies.jar
输出:
$ java -jar target/derby-embedded-data-source-locale-1.0-SNAPSHOT-jar-with-dependencies.jar
Picked up JAVA_TOOL_OPTIONS: -Duser.language=en
running main
Exception in thread "main" java.sql.SQLNonTransientConnectionException: The connection was refused because the database database was not found.
at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
at de.richtercloud.derby.embedded.data.source.locale.Main.main(Main.java:12)
Caused by: ERROR 08004: The connection was refused because the database database was not found.
at org.apache.derby.client.net.NetConnectionReply.parseRDBNFNRM(Unknown Source)
at org.apache.derby.client.net.NetConnectionReply.parseAccessRdbError(Unknown Source)
at org.apache.derby.client.net.NetConnectionReply.parseACCRDBreply(Unknown Source)
at org.apache.derby.client.net.NetConnectionReply.readAccessDatabase(Unknown Source)
at org.apache.derby.client.net.NetConnection.readSecurityCheckAndAccessRdb(Unknown Source)
at org.apache.derby.client.net.NetConnection.flowSecurityCheckAndAccessRdb(Unknown Source)
at org.apache.derby.client.net.NetConnection.flowUSRIDPWDconnect(Unknown Source)
at org.apache.derby.client.net.NetConnection.flowConnect(Unknown Source)
at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl.newNetConnection(Unknown Source)
... 4 more
ERROR: Job failed: exit code 1
FATAL: exit code 1