我在Spring启动中的项目。我的项目中有一个外部jar文件,并且仅通过Build路径添加。当我使用maven clean install命令运行项目时。我收到以下错误消息:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/Code/workspace/NestOrion/src/main/java/orion/trader/individual/IndividualOrderTrader.java:[16,33] package com.omnesys.nestq.classes does not exist
[ERROR] /D:/Code/workspace/NestOrion/src/main/java/orion/trader/individual/IndividualOrderTrader.java:[17,33] package com.omnesys.nestq.classes does not exist
[ERROR] /D:/Code/workspace/NestOrion/src/main/java/orion/trader/individual/IndividualOrderTrader.java:[36,28] cannot find symbol
Pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
<mainClass>
com.orion.main.NestOrionApplication
</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我也根据他们阅读了一些文章,有时在运行时找不到外部jar文件路径,因此我们需要java classpath(源附件)。所以我通过构建路径> jar>添加的源附件添加了。但是我仍然遇到相同的编译错误。
答案 0 :(得分:0)
在maven依赖项中添加了外部jar之后,它解决了我的问题。
步骤:
罐子的名称:ReleaseVersion.jar
<dependency>
<groupId>DealerNestQApiReleaseVersion</groupId>
<artifactId>DealerNestQApiReleaseVersion</artifactId>
<scope>system</scope>
<version>1.1</version>
<systemPath>${basedir}/libs/DealerNestQApiReleaseVersion.jar</systemPath>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
通过此步骤,我解决了我的问题。