在将Spring Boot从1.5.21升级到2.3.4之后,单元测试中出现了SQL语法错误。

huangapple go评论78阅读模式
英文:

SQL syntax error in unit tests, after upgrade from Spring Boot 1.5.21 to 2.3.4

问题

有一个使用了Spring Boot 1.5.21编写的应用程序。我被要求将其升级到Spring Boot 2.3.4,并修复升级引发的错误。显然,这并没有进行得很顺利,因为我在许多方面只是一个初学者。通过Google搜索,我已经能够解决一些由于依赖项更改而引起的错误。但是我要询问的这个错误花费了我几个小时,但我甚至没有找到线索。

直接来说,这是IntelliJ显示的错误消息:

迁移 V1.0.0__20170401_Create_initial_tables.sql 失败
-----------------------------------------------------------
SQL 状态: 42000
错误代码: 42000
消息: SQL 语句中的语法错误 "ALTER SEQUENCE ACCOUNT_ACCOUNT_ID_SEQ OWNED[*] BY ACCOUNT.ACCOUNT_ID";SQL 语句:
ALTER SEQUENCE account_account_id_seq OWNED BY account.account_id [42000-200]
位置:db/migration/V1.0.0__20170401_Create_initial_tables.sql (/Users/pei/Documents/workspace/gmark-entry/gmark-entry-common/target/classes/db/migration/V1.0.0__20170401_Create_initial_tables.sql)
行:56
语句:ALTER SEQUENCE account_account_id_seq OWNED BY account.account_id

有 180 个测试在几个测试类中。使用 Spring Boot 1.5.21 时,所有测试都通过而没有错误,而现在在 Spring Boot 2.3.4 中有 28 个测试以相同的错误消息失败。

我目前的理解是,该应用程序使用 PostgreSQL,而 src/main/resources/db.migration/V1.0.0__20170401_Create_initial_tables.sql 使用 PostgreSQL 语法编写,特别是在错误消息中指出的行中的 OWNED

ALTER SEQUENCE account_account_id_seq OWNED BY account.account_id

似乎当 Spring Boot 运行测试时,数据库不是 PostgreSQL 而是 H2,而 H2 无法理解 PostgreSQL 语法(方言?)。

但是为什么在 Spring Boot 1.5.21 中不会出现此错误呢?我该如何修复这个问题?

我迄今为止发现的另一个问题是,错误与每个测试用例都无关,而是在测试用例到达之前发生。这可以通过在测试用例开头设置断点并进行调试来确认。此外,如果我注释掉测试类的 @RunWith(SpringRunner.class) 注解,迁移中的语法错误就不再出现,测试用例体被执行,但显然某些初始化步骤不正确,因此测试仍然以另一个错误失败:

/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=51525:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath ...(略)
英文:

There is an application written with Spring Boot 1.5.21. I'm asked to upgrade it to Spring Boot 2.3.4, and fix the errors the upgrade brings. Apparently, this didn't go well since I'm merely a beginner on many things. I've been able to solve some errors due to dependency changes, by googling. But the one I'm going to ask took me hours yet I didn't even see a clue of it.

Directly this is the error message shown by IntelliJ:

Migration V1.0.0__20170401_Create_initial_tables.sql failed
-----------------------------------------------------------
SQL State  : 42000
Error Code : 42000
Message    : Syntax error in SQL statement "ALTER SEQUENCE ACCOUNT_ACCOUNT_ID_SEQ OWNED[*] BY ACCOUNT.ACCOUNT_ID"; SQL statement:
ALTER SEQUENCE account_account_id_seq OWNED BY account.account_id [42000-200]
Location   : db/migration/V1.0.0__20170401_Create_initial_tables.sql (/Users/pei/Documents/workspace/gmark-entry/gmark-entry-common/target/classes/db/migration/V1.0.0__20170401_Create_initial_tables.sql)
Line       : 56
Statement  : ALTER SEQUENCE account_account_id_seq OWNED BY account.account_id

There are 180 tests in several test classes. With Spring Boot 1.5.21 all of them pass without an error, and now 28 of them failed with the same error message above, with Spring Boot 2.3.4.

Here is my understanding so far. The application uses PostgreSQL, and src/main/resources/db.migration/V1.0.0__20170401_Create_initial_tables.sql is written with PostgreSQL syntax, especially OWNED in the line

ALTER SEQUENCE account_account_id_seq OWNED BY account.account_id

as pointed out in the error message. It seems like the database is not PostgreSQL but H2 when Spring Boot runs the tests, and H2 failed to understand the PostgreSQL syntax (dialect?).

But why this error doesn't pop up with Spring Boot 1.5.21? And how do I fix this?

Something else I found so far: the error has nothing to do with each test case, but happens before a test case is reached. This is confirmed by simply setting a breakpoint at the beginning of a test case and debugging it. Moreover, if I comment out @RunWith(SpringRunner.class) the annotation of the test class, the syntax error in migration doesn't appear anymore, and test case body is reached, but apparently something is not initialized correctly then and the test still fails with another error

/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=51525:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit5-rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/tools.jar:/Users/pei/Documents/workspace/gmark-entry/gmark-entry-common/target/test-classes:/Users/pei/Documents/workspace/gmark-entry/gmark-entry-common/target/classes:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/2.3.4.RELEASE/spring-boot-starter-data-jpa-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.3.4.RELEASE/spring-boot-starter-aop-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/aspectj/aspectjweaver/1.9.6/aspectjweaver-1.9.6.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.3.4.RELEASE/spring-boot-starter-jdbc-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/com/zaxxer/HikariCP/3.4.5/HikariCP-3.4.5.jar:/Users/pei/.m2/repository/org/springframework/spring-jdbc/5.2.9.RELEASE/spring-jdbc-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3.jar:/Users/pei/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar:/Users/pei/.m2/repository/org/hibernate/hibernate-core/5.4.21.Final/hibernate-core-5.4.21.Final.jar:/Users/pei/.m2/repository/org/javassist/javassist/3.24.0-GA/javassist-3.24.0-GA.jar:/Users/pei/.m2/repository/net/bytebuddy/byte-buddy/1.10.14/byte-buddy-1.10.14.jar:/Users/pei/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/pei/.m2/repository/org/jboss/jandex/2.1.3.Final/jandex-2.1.3.Final.jar:/Users/pei/.m2/repository/com/fasterxml/classmate/1.5.1/classmate-1.5.1.jar:/Users/pei/.m2/repository/org/dom4j/dom4j/2.1.3/dom4j-2.1.3.jar:/Users/pei/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.1.0.Final/hibernate-commons-annotations-5.1.0.Final.jar:/Users/pei/.m2/repository/org/springframework/data/spring-data-jpa/2.3.4.RELEASE/spring-data-jpa-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/data/spring-data-commons/2.3.4.RELEASE/spring-data-commons-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-orm/5.2.9.RELEASE/spring-orm-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-tx/5.2.9.RELEASE/spring-tx-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar:/Users/pei/.m2/repository/org/springframework/spring-aspects/5.2.9.RELEASE/spring-aspects-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-starter-data-redis/2.3.4.RELEASE/spring-boot-starter-data-redis-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-starter/2.3.4.RELEASE/spring-boot-starter-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot/2.3.4.RELEASE/spring-boot-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.3.4.RELEASE/spring-boot-autoconfigure-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.3.4.RELEASE/spring-boot-starter-logging-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/Users/pei/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/Users/pei/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.13.3/log4j-to-slf4j-2.13.3.jar:/Users/pei/.m2/repository/org/apache/logging/log4j/log4j-api/2.13.3/log4j-api-2.13.3.jar:/Users/pei/.m2/repository/org/slf4j/jul-to-slf4j/1.7.30/jul-to-slf4j-1.7.30.jar:/Users/pei/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/pei/.m2/repository/org/yaml/snakeyaml/1.26/snakeyaml-1.26.jar:/Users/pei/.m2/repository/org/springframework/data/spring-data-redis/2.3.4.RELEASE/spring-data-redis-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/data/spring-data-keyvalue/2.3.4.RELEASE/spring-data-keyvalue-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-oxm/5.2.9.RELEASE/spring-oxm-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/io/lettuce/lettuce-core/5.3.4.RELEASE/lettuce-core-5.3.4.RELEASE.jar:/Users/pei/.m2/repository/io/netty/netty-common/4.1.52.Final/netty-common-4.1.52.Final.jar:/Users/pei/.m2/repository/io/netty/netty-handler/4.1.52.Final/netty-handler-4.1.52.Final.jar:/Users/pei/.m2/repository/io/netty/netty-resolver/4.1.52.Final/netty-resolver-4.1.52.Final.jar:/Users/pei/.m2/repository/io/netty/netty-buffer/4.1.52.Final/netty-buffer-4.1.52.Final.jar:/Users/pei/.m2/repository/io/netty/netty-codec/4.1.52.Final/netty-codec-4.1.52.Final.jar:/Users/pei/.m2/repository/io/netty/netty-transport/4.1.52.Final/netty-transport-4.1.52.Final.jar:/Users/pei/.m2/repository/io/projectreactor/reactor-core/3.3.10.RELEASE/reactor-core-3.3.10.RELEASE.jar:/Users/pei/.m2/repository/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-starter-mail/2.3.4.RELEASE/spring-boot-starter-mail-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-context-support/5.2.9.RELEASE/spring-context-support-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/com/sun/mail/jakarta.mail/1.6.5/jakarta.mail-1.6.5.jar:/Users/pei/.m2/repository/com/sun/activation/jakarta.activation/1.2.2/jakarta.activation-1.2.2.jar:/Users/pei/.m2/repository/org/springframework/spring-webmvc/5.2.9.RELEASE/spring-webmvc-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-aop/5.2.9.RELEASE/spring-aop-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-beans/5.2.9.RELEASE/spring-beans-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-context/5.2.9.RELEASE/spring-context-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-core/5.2.9.RELEASE/spring-core-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-jcl/5.2.9.RELEASE/spring-jcl-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-expression/5.2.9.RELEASE/spring-expression-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/spring-web/5.2.9.RELEASE/spring-web-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/security/spring-security-core/5.3.4.RELEASE/spring-security-core-5.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/session/spring-session-data-redis/2.3.1.RELEASE/spring-session-data-redis-2.3.1.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/session/spring-session-core/2.3.1.RELEASE/spring-session-core-2.3.1.RELEASE.jar:/Users/pei/.m2/repository/org/hibernate/hibernate-java8/5.4.21.Final/hibernate-java8-5.4.21.Final.jar:/Users/pei/.m2/repository/org/jboss/logging/jboss-logging/3.4.1.Final/jboss-logging-3.4.1.Final.jar:/Users/pei/.m2/repository/org/hibernate/hibernate-jpamodelgen/5.4.21.Final/hibernate-jpamodelgen-5.4.21.Final.jar:/Users/pei/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar:/Users/pei/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar:/Users/pei/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.3/jaxb-runtime-2.3.3.jar:/Users/pei/.m2/repository/org/glassfish/jaxb/txw2/2.3.3/txw2-2.3.3.jar:/Users/pei/.m2/repository/com/sun/istack/istack-commons-runtime/3.0.11/istack-commons-runtime-3.0.11.jar:/Users/pei/.m2/repository/org/freemarker/freemarker/2.3.30/freemarker-2.3.30.jar:/Users/pei/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.11.2/jackson-databind-2.11.2.jar:/Users/pei/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.11.2/jackson-annotations-2.11.2.jar:/Users/pei/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.11.2/jackson-core-2.11.2.jar:/Users/pei/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-hibernate5/2.11.2/jackson-datatype-hibernate5-2.11.2.jar:/Users/pei/.m2/repository/javax/transaction/javax.transaction-api/1.3/javax.transaction-api-1.3.jar:/Users/pei/.m2/repository/joda-time/joda-time/2.10.6/joda-time-2.10.6.jar:/Users/pei/.m2/repository/com/mortennobel/java-image-scaling/0.8.6/java-image-scaling-0.8.6.jar:/Users/pei/.m2/repository/com/jhlabs/filters/2.0.235/filters-2.0.235.jar:/Users/pei/.m2/repository/org/bytedeco/javacv-platform/1.4/javacv-platform-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacv/1.4/javacv-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp/1.4/javacpp-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv/3.4.0-1.4/opencv-3.4.0-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg/3.4.1-1.4/ffmpeg-3.4.1-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flycapture/2.11.3.121-1.4/flycapture-2.11.3.121-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libdc1394/2.2.5-1.4/libdc1394-2.2.5-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect/0.5.3-1.4/libfreenect-0.5.3-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect2/0.2.0-1.4/libfreenect2-0.2.0-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/librealsense/1.12.1-1.4/librealsense-1.12.1-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/videoinput/0.200-1.4/videoinput-0.200-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus/2.3.1-1.4/artoolkitplus-2.3.1-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark/1.07-1.4/flandmark-1.07-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv-platform/3.4.0-1.4/opencv-platform-3.4.0-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv/3.4.0-1.4/opencv-3.4.0-1.4-android-arm.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv/3.4.0-1.4/opencv-3.4.0-1.4-android-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv/3.4.0-1.4/opencv-3.4.0-1.4-linux-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv/3.4.0-1.4/opencv-3.4.0-1.4-linux-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv/3.4.0-1.4/opencv-3.4.0-1.4-linux-armhf.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv/3.4.0-1.4/opencv-3.4.0-1.4-linux-ppc64le.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv/3.4.0-1.4/opencv-3.4.0-1.4-macosx-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv/3.4.0-1.4/opencv-3.4.0-1.4-windows-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/opencv/3.4.0-1.4/opencv-3.4.0-1.4-windows-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg-platform/3.4.1-1.4/ffmpeg-platform-3.4.1-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg/3.4.1-1.4/ffmpeg-3.4.1-1.4-android-arm.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg/3.4.1-1.4/ffmpeg-3.4.1-1.4-android-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg/3.4.1-1.4/ffmpeg-3.4.1-1.4-linux-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg/3.4.1-1.4/ffmpeg-3.4.1-1.4-linux-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg/3.4.1-1.4/ffmpeg-3.4.1-1.4-linux-armhf.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg/3.4.1-1.4/ffmpeg-3.4.1-1.4-linux-ppc64le.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg/3.4.1-1.4/ffmpeg-3.4.1-1.4-macosx-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg/3.4.1-1.4/ffmpeg-3.4.1-1.4-windows-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/ffmpeg/3.4.1-1.4/ffmpeg-3.4.1-1.4-windows-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flycapture-platform/2.11.3.121-1.4/flycapture-platform-2.11.3.121-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flycapture/2.11.3.121-1.4/flycapture-2.11.3.121-1.4-linux-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flycapture/2.11.3.121-1.4/flycapture-2.11.3.121-1.4-linux-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flycapture/2.11.3.121-1.4/flycapture-2.11.3.121-1.4-linux-armhf.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flycapture/2.11.3.121-1.4/flycapture-2.11.3.121-1.4-windows-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flycapture/2.11.3.121-1.4/flycapture-2.11.3.121-1.4-windows-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libdc1394-platform/2.2.5-1.4/libdc1394-platform-2.2.5-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libdc1394/2.2.5-1.4/libdc1394-2.2.5-1.4-linux-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libdc1394/2.2.5-1.4/libdc1394-2.2.5-1.4-linux-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libdc1394/2.2.5-1.4/libdc1394-2.2.5-1.4-linux-armhf.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libdc1394/2.2.5-1.4/libdc1394-2.2.5-1.4-linux-ppc64le.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libdc1394/2.2.5-1.4/libdc1394-2.2.5-1.4-macosx-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libdc1394/2.2.5-1.4/libdc1394-2.2.5-1.4-windows-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libdc1394/2.2.5-1.4/libdc1394-2.2.5-1.4-windows-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect-platform/0.5.3-1.4/libfreenect-platform-0.5.3-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect/0.5.3-1.4/libfreenect-0.5.3-1.4-linux-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect/0.5.3-1.4/libfreenect-0.5.3-1.4-linux-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect/0.5.3-1.4/libfreenect-0.5.3-1.4-linux-armhf.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect/0.5.3-1.4/libfreenect-0.5.3-1.4-linux-ppc64le.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect/0.5.3-1.4/libfreenect-0.5.3-1.4-macosx-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect/0.5.3-1.4/libfreenect-0.5.3-1.4-windows-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect/0.5.3-1.4/libfreenect-0.5.3-1.4-windows-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect2-platform/0.2.0-1.4/libfreenect2-platform-0.2.0-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect2/0.2.0-1.4/libfreenect2-0.2.0-1.4-linux-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect2/0.2.0-1.4/libfreenect2-0.2.0-1.4-linux-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect2/0.2.0-1.4/libfreenect2-0.2.0-1.4-macosx-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/libfreenect2/0.2.0-1.4/libfreenect2-0.2.0-1.4-windows-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/librealsense-platform/1.12.1-1.4/librealsense-platform-1.12.1-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/librealsense/1.12.1-1.4/librealsense-1.12.1-1.4-linux-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/librealsense/1.12.1-1.4/librealsense-1.12.1-1.4-linux-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/librealsense/1.12.1-1.4/librealsense-1.12.1-1.4-macosx-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/librealsense/1.12.1-1.4/librealsense-1.12.1-1.4-windows-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/librealsense/1.12.1-1.4/librealsense-1.12.1-1.4-windows-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/videoinput-platform/0.200-1.4/videoinput-platform-0.200-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/videoinput/0.200-1.4/videoinput-0.200-1.4-windows-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/videoinput/0.200-1.4/videoinput-0.200-1.4-windows-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus-platform/2.3.1-1.4/artoolkitplus-platform-2.3.1-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus/2.3.1-1.4/artoolkitplus-2.3.1-1.4-android-arm.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus/2.3.1-1.4/artoolkitplus-2.3.1-1.4-android-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus/2.3.1-1.4/artoolkitplus-2.3.1-1.4-linux-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus/2.3.1-1.4/artoolkitplus-2.3.1-1.4-linux-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus/2.3.1-1.4/artoolkitplus-2.3.1-1.4-linux-armhf.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus/2.3.1-1.4/artoolkitplus-2.3.1-1.4-linux-ppc64le.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus/2.3.1-1.4/artoolkitplus-2.3.1-1.4-macosx-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus/2.3.1-1.4/artoolkitplus-2.3.1-1.4-windows-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/artoolkitplus/2.3.1-1.4/artoolkitplus-2.3.1-1.4-windows-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark-platform/1.07-1.4/flandmark-platform-1.07-1.4.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark/1.07-1.4/flandmark-1.07-1.4-android-arm.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark/1.07-1.4/flandmark-1.07-1.4-android-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark/1.07-1.4/flandmark-1.07-1.4-linux-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark/1.07-1.4/flandmark-1.07-1.4-linux-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark/1.07-1.4/flandmark-1.07-1.4-linux-armhf.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark/1.07-1.4/flandmark-1.07-1.4-linux-ppc64le.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark/1.07-1.4/flandmark-1.07-1.4-macosx-x86_64.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark/1.07-1.4/flandmark-1.07-1.4-windows-x86.jar:/Users/pei/.m2/repository/org/bytedeco/javacpp-presets/flandmark/1.07-1.4/flandmark-1.07-1.4-windows-x86_64.jar:/Users/pei/.m2/repository/org/flywaydb/flyway-core/6.4.4/flyway-core-6.4.4.jar:/Users/pei/.m2/repository/org/apache/pdfbox/pdfbox-tools/2.0.8/pdfbox-tools-2.0.8.jar:/Users/pei/.m2/repository/org/apache/pdfbox/pdfbox-debugger/2.0.8/pdfbox-debugger-2.0.8.jar:/Users/pei/.m2/repository/org/apache/pdfbox/pdfbox/2.0.8/pdfbox-2.0.8.jar:/Users/pei/.m2/repository/org/apache/pdfbox/fontbox/2.0.8/fontbox-2.0.8.jar:/Users/pei/.m2/repository/org/apache/httpcomponents/httpclient/4.5.12/httpclient-4.5.12.jar:/Users/pei/.m2/repository/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar:/Users/pei/.m2/repository/commons-codec/commons-codec/1.14/commons-codec-1.14.jar:/Users/pei/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar:/Users/pei/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/Users/pei/.m2/repository/commons-validator/commons-validator/1.4.0/commons-validator-1.4.0.jar:/Users/pei/.m2/repository/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar:/Users/pei/.m2/repository/commons-digester/commons-digester/1.8/commons-digester-1.8.jar:/Users/pei/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/pei/.m2/repository/org/postgresql/postgresql/9.4.1212/postgresql-9.4.1212.jar:/Users/pei/.m2/repository/org/projectlombok/lombok/1.18.12/lombok-1.18.12.jar:/Users/pei/.m2/repository/javax/servlet/javax.servlet-api/4.0.1/javax.servlet-api-4.0.1.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-starter-test/2.3.4.RELEASE/spring-boot-starter-test-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-test/2.3.4.RELEASE/spring-boot-test-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/org/springframework/boot/spring-boot-test-autoconfigure/2.3.4.RELEASE/spring-boot-test-autoconfigure-2.3.4.RELEASE.jar:/Users/pei/.m2/repository/com/jayway/jsonpath/json-path/2.4.0/json-path-2.4.0.jar:/Users/pei/.m2/repository/net/minidev/json-smart/2.3/json-smart-2.3.jar:/Users/pei/.m2/repository/net/minidev/accessors-smart/1.2/accessors-smart-1.2.jar:/Users/pei/.m2/repository/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar:/Users/pei/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar:/Users/pei/.m2/repository/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar:/Users/pei/.m2/repository/org/assertj/assertj-core/3.16.1/assertj-core-3.16.1.jar:/Users/pei/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/Users/pei/.m2/repository/org/junit/jupiter/junit-jupiter/5.6.2/junit-jupiter-5.6.2.jar:/Users/pei/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.6.2/junit-jupiter-api-5.6.2.jar:/Users/pei/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/Users/pei/.m2/repository/org/junit/platform/junit-platform-commons/1.6.2/junit-platform-commons-1.6.2.jar:/Users/pei/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.6.2/junit-jupiter-params-5.6.2.jar:/Users/pei/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.6.2/junit-jupiter-engine-5.6.2.jar:/Users/pei/.m2/repository/org/junit/vintage/junit-vintage-engine/5.6.2/junit-vintage-engine-5.6.2.jar:/Users/pei/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar:/Users/pei/.m2/repository/org/junit/platform/junit-platform-engine/1.6.2/junit-platform-engine-1.6.2.jar:/Users/pei/.m2/repository/junit/junit/4.13/junit-4.13.jar:/Users/pei/.m2/repository/org/mockito/mockito-core/3.3.3/mockito-core-3.3.3.jar:/Users/pei/.m2/repository/net/bytebuddy/byte-buddy-agent/1.10.14/byte-buddy-agent-1.10.14.jar:/Users/pei/.m2/repository/org/objenesis/objenesis/2.6/objenesis-2.6.jar:/Users/pei/.m2/repository/org/mockito/mockito-junit-jupiter/3.3.3/mockito-junit-jupiter-3.3.3.jar:/Users/pei/.m2/repository/org/skyscreamer/jsonassert/1.5.0/jsonassert-1.5.0.jar:/Users/pei/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar:/Users/pei/.m2/repository/org/springframework/spring-test/5.2.9.RELEASE/spring-test-5.2.9.RELEASE.jar:/Users/pei/.m2/repository/org/xmlunit/xmlunit-core/2.7.0/xmlunit-core-2.7.0.jar:/Users/pei/.m2/repository/com/icegreen/greenmail-spring/1.5.10/greenmail-spring-1.5.10.jar:/Users/pei/.m2/repository/com/icegreen/greenmail/1.5.10/greenmail-1.5.10.jar:/Users/pei/.m2/repository/com/sun/mail/javax.mail/1.5.6/javax.mail-1.5.6.jar:/Users/pei/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar:/Users/pei/.m2/repository/com/h2database/h2/1.4.200/h2-1.4.200.jar:/Users/pei/.m2/repository/org/apache/commons/commons-collections4/4.4/commons-collections4-4.4.jar com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 org.g_mark.common.entity.AgreementTests,mapping
java.lang.NullPointerException
at org.g_mark.common.entity.AgreementTests.mapping(AgreementTests.java:61)
...
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Process finished with exit code 255

答案1

得分: 1

解决方案很简单,而且在我看来也很愚蠢。

src/test/resources/application.yml 中,之前是这样的:

spring:
...
flyway:
enabled: false

将其更改为以下内容后问题得到解决:

spring:
...
flyway:
enabled: false

我猜是从 Spring Boot 1 更改到了 2?

英文:

The solution is simple and also really silly IMHO.

In src/test/resources/application.yml, previously it was

spring:
...
flyway:
enabled: false

Problem solved after changing that to

spring:
...
flyway:
enabled: false

Format change from Spring Boot 1 to 2 I guess?

huangapple
  • 本文由 发表于 2020年10月1日 15:21:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/64150745.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定