如何将 sqlite-jdbc 项目迁移到 java-11;未命名模块从 junit 和 hamcrest.core 中读取包 org.hamcrest
How to migrate sqlite-jdbc project to java-11; the unnamed module reads package org.hamcrest from both junit and hamcrest.core
我无法将我的 maven 项目从 Java 8 迁移到 Java 11。我需要如何解决模块依赖关系?
我已经将模块 module-info.java
和命令行编译定义为
mvn clean install
运行良好,但不能 运行 IntelliJ 中的项目 IDEA.
pom.xml
<?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>
<groupId>vk-post-searcher</groupId>
<artifactId>VKPostSearcher</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>VKPostSearcher</finalName>
<archive>
<manifest>
<mainClass>etu.wollen.vk.PostSearcher</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.28.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
模块-info.java
module etu.wollen.vk {
requires java.sql;
requires sqlite.jdbc;
requires json.simple;
exports etu.wollen.vk;
}
我从 IDE 得到一堆错误 运行ning:
Error:java: the unnamed module reads package org.hamcrest from both junit and hamcrest.core
Error:java: the unnamed module reads package org.hamcrest.internal from both junit and hamcrest.core
Error:java: the unnamed module reads package org.hamcrest.core from both junit and hamcrest.core
Error:java: module junit reads package org.hamcrest from both junit and hamcrest.core
Error:java: module junit reads package org.hamcrest.internal from both junit and hamcrest.core
Error:java: module junit reads package org.hamcrest.core from both junit and hamcrest.core
Error:java: module hamcrest.core reads package org.hamcrest from both junit and hamcrest.core
Error:java: module hamcrest.core reads package org.hamcrest.internal from both junit and hamcrest.core
Error:java: module hamcrest.core reads package org.hamcrest.core from both junit and hamcrest.core
Error:java: module json.simple reads package org.hamcrest from both junit and hamcrest.core
Error:java: module json.simple reads package org.hamcrest.internal from both junit and hamcrest.core
Error:java: module json.simple reads package org.hamcrest.core from both junit and hamcrest.core
Error:java: module sqlite.jdbc reads package org.hamcrest from both junit and hamcrest.core
Error:java: module sqlite.jdbc reads package org.hamcrest.internal from both junit and hamcrest.core
Error:java: module sqlite.jdbc reads package org.hamcrest.core from both junit and hamcrest.core
C:\Projects\IDEAProjects\VKpostSearcher\src\main\java\module-info.java
Error:(1, 1) java: module etu.wollen.vk reads package org.hamcrest from both junit and hamcrest.core
我以前遇到过这个确切的问题,我相信我通过添加以下依赖项修复了它:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.1</version>
<scope>test</scope>
</dependency>
如果这不能解决您的问题,请告诉我。
我无法将我的 maven 项目从 Java 8 迁移到 Java 11。我需要如何解决模块依赖关系?
我已经将模块 module-info.java
和命令行编译定义为
mvn clean install
运行良好,但不能 运行 IntelliJ 中的项目 IDEA.
pom.xml
<?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>
<groupId>vk-post-searcher</groupId>
<artifactId>VKPostSearcher</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>VKPostSearcher</finalName>
<archive>
<manifest>
<mainClass>etu.wollen.vk.PostSearcher</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.28.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
模块-info.java
module etu.wollen.vk {
requires java.sql;
requires sqlite.jdbc;
requires json.simple;
exports etu.wollen.vk;
}
我从 IDE 得到一堆错误 运行ning:
Error:java: the unnamed module reads package org.hamcrest from both junit and hamcrest.core
Error:java: the unnamed module reads package org.hamcrest.internal from both junit and hamcrest.core
Error:java: the unnamed module reads package org.hamcrest.core from both junit and hamcrest.core
Error:java: module junit reads package org.hamcrest from both junit and hamcrest.core
Error:java: module junit reads package org.hamcrest.internal from both junit and hamcrest.core
Error:java: module junit reads package org.hamcrest.core from both junit and hamcrest.core
Error:java: module hamcrest.core reads package org.hamcrest from both junit and hamcrest.core
Error:java: module hamcrest.core reads package org.hamcrest.internal from both junit and hamcrest.core
Error:java: module hamcrest.core reads package org.hamcrest.core from both junit and hamcrest.core
Error:java: module json.simple reads package org.hamcrest from both junit and hamcrest.core
Error:java: module json.simple reads package org.hamcrest.internal from both junit and hamcrest.core
Error:java: module json.simple reads package org.hamcrest.core from both junit and hamcrest.core
Error:java: module sqlite.jdbc reads package org.hamcrest from both junit and hamcrest.core
Error:java: module sqlite.jdbc reads package org.hamcrest.internal from both junit and hamcrest.core
Error:java: module sqlite.jdbc reads package org.hamcrest.core from both junit and hamcrest.core
C:\Projects\IDEAProjects\VKpostSearcher\src\main\java\module-info.java
Error:(1, 1) java: module etu.wollen.vk reads package org.hamcrest from both junit and hamcrest.core
我以前遇到过这个确切的问题,我相信我通过添加以下依赖项修复了它:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.1</version>
<scope>test</scope>
</dependency>
如果这不能解决您的问题,请告诉我。