【发布时间】:2021-03-24 19:00:14
【问题描述】:
我拿了一个项目并在 Eclipse 中复制了它,现在当我运行 maven 命令编译它时,由于缺少变量而出现错误。被引用的代码在旧项目中,我需要知道如何让构建过程识别新项目中的代码而不是旧项目。
这是我在命令提示符下得到的。
它应该引用的项目文件是新项目中的 OpenExcel.java,但它引用的是旧项目 VegaAutomatisierungPart1 中的文件。
我需要知道如何让它引用新项目,我尝试查看项目文件夹中的所有文件,但我没有看到任何关于引用旧项目的内容,所以我不知道该怎么做做。
这是我的 pom.xml。
<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>VegaAutomatisierungPart1</groupId>
<artifactId>VegaAutomatisierungPart1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.7</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
这是它引用的代码。
【问题讨论】:
-
似乎是从新项目编译代码(错误消息中的路径包含
../AutomatisierteAnlaufsteuerung/..)。似乎有问题的是您复制项目的pom.xml文件中定义的groupId和artifactId -
你知道我应该改变什么吗?我在问题中发布了我的 pom.xml。
-
正如我在第一条评论中所写:您应该更改
groupId和artifactId- 在您的 POM 中,它们位于第 5 行和第 6 行(而不是<groupId>VegaAutomatisierungPart1</groupId>,它可能应该是<groupId>AutomatisierteAnlaufsteuerung</groupId>,对于artifactId类似的东西) -
这改变了文本,但它仍然在与旧项目相同的行上返回相同的变量,并且它没有在新项目中使用新代码。
-
错误信息
/C:/Users/D171_o_QECJACK031/eclipse-workspace/AutomatisierteAnlaufsteuerung/src/OpenExcel.java:[50,67] cannot find symbol明确指出它试图从项目的默认包AutomatisierteAnlaufsteuerung编译文件OpenExcel.java。