在Java中导入toml4j失败
我正试图导入到我的maven项目中。我在依赖项部分的POM.xml中将其添加到我的依赖项中:在Java中导入toml4j失败,java,maven,toml,Java,Maven,Toml,我正试图导入到我的maven项目中。我在依赖项部分的POM.xml中将其添加到我的依赖项中: <dependency> <groupId>com.moandjiezana.toml</groupId> <artifactId>toml4j</artifactId> <version>0.7.2</version> </dependency> 在我的主文件中,它不识别“moan
<dependency>
<groupId>com.moandjiezana.toml</groupId>
<artifactId>toml4j</artifactId>
<version>0.7.2</version>
</dependency>
在我的主文件中,它不识别“moandjiezana”部分
在此处编辑2:POM.xml完整文件:
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress MavenModelInspection -->
<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>com.comp.ima.restmesspc</groupId>
<artifactId>RESTMessPC</artifactId>
<version>0.1-SNAPSHOT</version>
<name>RESTMessPC</name>
<!-- FIXME change it to the project's website -->
<url>http://www.maven.apache.org.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.moandjiezana.toml/toml4j -->
<dependency>
<groupId>com.moandjiezana.toml</groupId>
<artifactId>toml4j</artifactId>
<version>0.7.2</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
我确实安装了JDK,IntelliJ可以识别它
编辑4:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/Environments/Java/restmesspc/src/main/java/com/comp/ima/restmess
pc/App.java:[8,29] cannot find symbol
symbol: class toml4j
location: package com.moandjiezana.toml
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.432 s
[INFO] Finished at: 2018-04-17T19:30:39+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
7.0:compile (default-compile) on project RESTMessPC: Compilation failure
[ERROR] /D:/Environments/Java/restmesspc/src/main/java/com/comp/ima/restmess
pc/App.java:[8,29] cannot find symbol
[ERROR] symbol: class toml4j
[ERROR] location: package com.moandjiezana.toml
请按照以下步骤操作:-
set JAVA\u HOME=C:\Program Files\JAVA\jdk1.8.0\u 31
正确设置JAVA主页好的,经过进一步的研究,我发现IntelliJ基本上不想写入已经失败的导入文件夹
因此,删除要在
C:\user\[user]\.m2\repository
中导入的依赖项文件夹并重新导入应该可以解决问题。实际上,我可以从maven下载上述工件。希望您可以通过internet访问远程回购下载。我确实可以通过代理服务器连接internet。我甚至可以通过IntelliJ ping存储库@ConferenceQuestintellij具有自动导入功能。转到设置-->搜索“自动导入”。启用它。一旦完成,IntelliJ应该自动从repo获取依赖项。它已经启用,但仍然不起作用。对不起,如果我表现得很愚蠢,但是我对使用maven还相当陌生。你在你的计算机上安装了maven吗?你使用的是windows还是Mac?您是否正确设置了MAVEN环境变量?这是你计算机上的第一个Maven项目吗?
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress MavenModelInspection -->
<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>com.comp.ima.restmesspc</groupId>
<artifactId>RESTMessPC</artifactId>
<version>0.1-SNAPSHOT</version>
<name>RESTMessPC</name>
<!-- FIXME change it to the project's website -->
<url>http://www.maven.apache.org.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.moandjiezana.toml/toml4j -->
<dependency>
<groupId>com.moandjiezana.toml</groupId>
<artifactId>toml4j</artifactId>
<version>0.7.2</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on
a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 36.301 s
[INFO] Finished at: 2018-04-17T19:08:28+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
7.0:compile (default-compile) on project RESTMessPC: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on
a JRE rather than a JDK?
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/Environments/Java/restmesspc/src/main/java/com/comp/ima/restmess
pc/App.java:[8,29] cannot find symbol
symbol: class toml4j
location: package com.moandjiezana.toml
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.432 s
[INFO] Finished at: 2018-04-17T19:30:39+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
7.0:compile (default-compile) on project RESTMessPC: Compilation failure
[ERROR] /D:/Environments/Java/restmesspc/src/main/java/com/comp/ima/restmess
pc/App.java:[8,29] cannot find symbol
[ERROR] symbol: class toml4j
[ERROR] location: package com.moandjiezana.toml