Проект maven-builds работает нормально, но когда я создаю module-info.java, я получаю «Разветвленная виртуальная машина прервана, не сказав прощания». - PullRequest
0 голосов
/ 01 мая 2019

У меня есть простой проект, который использует maven, spring-boot и подключается к базе данных postresql.Когда я запускаю mvn clean install, все работает нормально, даже тесты.(Я компилирую его с помощью java 10) Затем я добавляю module-info.java, чтобы превратить его в модуль java9.Теперь, если я собираю его, а я не использую -DskipTests, я получаю следующую ошибку:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project birdtree-model-dao: There are test failures.
[ERROR] 
[ERROR] Please refer to D:\Programming practice\Mentoring Donna Informatica\birdtree_project\birdtree_java_workspace\birdtree-model-dao\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk-10.0.1\bin\java" @C:\Users\Manuela\AppData\Local\Temp\surefire16709347194940961814\surefireargs14150574352838310253 C:\Users\Manuela\AppData\Local\Temp\surefire16709347194940961814 2019-05-01T01-23-43_537-jvmRun1 surefire9560741769530673276tmp surefire_08315816585779964257tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk-10.0.1\bin\java" @C:\Users\Manuela\AppData\Local\Temp\surefire16709347194940961814\surefireargs14150574352838310253 C:\Users\Manuela\AppData\Local\Temp\surefire16709347194940961814 2019-05-01T01-23-43_537-jvmRun1 surefire9560741769530673276tmp surefire_08315816585779964257tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669)
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
...

И файл верных отчетов содержит:

# Created at 2019-05-01T00:58:57.663
Error: Could not find or load main class practice\Mentoring

# Created at 2019-05-01T00:58:57.663
Caused by: java.lang.ClassNotFoundException: practice\Mentoring

(Звучит вроденапример, проблема в том, что в пути к файлу есть пробел, верно? Но если это так, где я могу это исправить?)

Итак, я полагаю, что это должна быть ошибка информации модуля, поскольку это единственноевещь, которая изменилась.Я боролся с тем, что положить в него.Один созданный Eclipse автоматически показался неверным, например, потому что он включает в себя тестовые зависимости, что дало мне другие ошибки.Итак, я попытался, и в настоящее время это выглядит так:

module birdtreeModelDao {
    exports mjl.familytree.birdtree;

    //requires junit; //eclipse adds this. But I think test dependencies don't belong here, right?
    requires spring.boot;
    requires spring.boot.autoconfigure; //included this externally by creating new library
    //requires spring.boot.test; //eclipse adds this. But it just gives me other errors. And again, it's a test dependency, so surely it shouldn't be here.
    requires spring.context;
}

Вот мой pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>mjl.familytree</groupId>
    <artifactId>birdtree-model-dao</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>birdtree-model-dao</name>
    <description>Manuela's family tree program</description>


    <repositories>
        <repository>
            <id>repository.spring.release</id>
            <name>Spring GA Repository</name>
            <url>http://repo.spring.io/release</url>
        </repository>
    </repositories>

    <properties>
        <maven.compiler.source>1.10</maven.compiler.source><!-- 1.12 -->
        <maven.compiler.target>1.10</maven.compiler.target><!-- 1.12 -->
        <maven.compiler.release>10</maven.compiler.release>
        <java.version>10</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <!-- <dependency> -->
        <!-- <groupId>org.springframework.boot</groupId> -->
        <!-- <artifactId>spring-boot-starter-data-rest</artifactId> -->
        <!-- </dependency> -->
        <!-- <dependency> -->
        <!-- <groupId>org.springframework.boot</groupId> -->
        <!-- <artifactId>spring-boot-starter-web</artifactId> -->
        <!-- </dependency> -->
        <!-- <dependency> -->
        <!-- <groupId>org.springframework.boot</groupId> -->
        <!-- <artifactId>spring-boot-starter-web-services</artifactId> -->
        <!-- </dependency> -->

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
<!--            <version>4.12</version> -->
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <!-- https://stackoverflow.com/questions/50661648/spring-boot-fails-to-run-maven-surefire-plugin-classnotfoundexception-org-apache/50661649#50661649 -->
            <!-- Used this to try to prevent "The forked VM terminated without properly saying goodbye" when running with tests and with module-info.java -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <useSystemClassLoader>false</useSystemClassLoader>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Есть идеи, что является причиной ошибки?

...