英文:
dependencies from pom.xml not being resolved
问题
我正在尝试在IntelliJ中创建一个Maven项目,用于使用ANTLR创建解析器。以下是我的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>com.mua</groupId>
<artifactId>json-parser-java-antlr</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Json parser Java ANTLR</name>
<packaging>jar</packaging>
<description>Trying to create a parser using ANTLR in Java, as facing problems with LLVM</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.io</artifactId>
</dependency>
</dependencies>
</project>
当我点击“导入更改”时,加载仅需1-2秒即可完成。但是,如果我尝试从org.apache.commons.collections4.MapUtils
导入MapUtils
,它会显示无法解析common
,尽管我已经添加了<groupId>org.apache.commons</groupId>
的依赖。
我在Maven项目创建和管理方面还是新手。
所以,问题出在哪里,我如何解决这个问题?
我研究了一些pom.xml
文件,并找到了一个parent
属性。不知道如何配置它。
英文:
I'm trying to create a maven project in intellij, to create a parser in antlr. Here is my 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>com.mua</groupId>
<artifactId>json-parser-java-antlr</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Json parser Java ANTLR</name>
<packaging>jar</packaging>
<description>Trying to create a parser using ANTLR in Java, as facing problems with LLVM</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.io</artifactId>
</dependency>
</dependencies>
</project>
When I click on import changes, it loads for just 1-2 seconds then done. But if I try to import MapUtils
from org.apache.commons.collections4.MapUtils
it says it can't resolve common
, although I added in <groupId>org.apache.commons</groupId>
dependency.
I'm new in maven project creation and management.
So, what is the problem here and how can I resolve this problem ?
I studied some pom.xml
and found a parent
attribute. No idea how to configure that.
答案1
得分: 0
我的 Eclipse 编辑器显示:
```lang-none
项目构建错误:缺少 org.antlr:antlr4-runtime:jar 的 'dependencies.dependency.version'。
项目构建错误:缺少 org.apache.commons:commons-collections4:jar 的 'dependencies.dependency.version'。
项目构建错误:缺少 org.apache.directory.studio:org.apache.commons.io:jar 的 'dependencies.dependency.version'。
由于它不知道您想要的这些依赖项的版本,因此没有任何依赖项能够正常工作。
在没有“父”POM 的情况下,指定依赖项而不包含版本信息是不可行的。您并没有使用“父”POM,因此版本是必需的。
<details>
<summary>英文:</summary>
My Eclipse editor shows:
```lang-none
Project build error: 'dependencies.dependency.version' for org.antlr:antlr4-runtime:jar is missing.
Project build error: 'dependencies.dependency.version' for org.apache.commons:commons-collections4:jar is missing.
Project build error: 'dependencies.dependency.version' for org.apache.directory.studio:org.apache.commons.io:jar is missing.
None of the dependencies work, because it doesn't know which version of them you want.
Specifying dependencies without a version is something you do when you have a parent pom. You don't, so versions are mandatory.
答案2
得分: 0
你可以尝试在你的 pom.xml 文件中添加特定版本的 antlr。如果你也在使用 antlr 插件,确保你使用的 antlr 运行时版本与插件内置版本相同。
英文:
You could try adding a specific version of antlr to your pom.xml. And if you are using the antlr plugin as well, make sure the version of antlr run-time you are using is the same as the built-in version of the plugin.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论