当我尝试编译为 Java App 时遇到问题,因为它找不到该类。
搜索网络后,堆栈溢出我发现我必须将类复制到类路径中,但正如您在图片中看到的那样,我没有那个依赖项,或者我的项目中没有那个类。
这里的图片:
这是我的 pom.xml:
<dependencies>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.6.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId>
<version>2.2</version>
<scope>compile</scope>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.3</version>
<inherited>true</inherited>
<configuration>
<download>true</download>
<schemaDirectory>src/main/resources</schemaDirectory>
<sourceGenerationDirectory>src/main/java</sourceGenerationDirectory>
<classGenerationDirectory>target/classes</classGenerationDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>package-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>se.sigma.educational.Main</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>target/generated-sources/axis2/wsdl2code/resources</directory>
</resource>
<resource>
<directory>target/generated-sources/xmlbeans/resources</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
(添加了</dependencies>标签,这里不显示)。
想告诉你,那个类在这个包中,但我不确定我是否可以使用它:
我以 maven build 运行,然后以 maven install 运行,此时一切正常(构建成功),但是当我尝试从主类调用它时出现错误。
如果您需要更多信息,请索取。