0

My project in Spring boot. I have one external jar file in my project and I added only through Build path. When I ran my project using maven clean install command. I got following error message :

[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>

I read other article also as per them some time external jar file path not found at run time so we need to java classpath (Source attachment). So I added through Build path > jar > added source attachment. But Still I am getting the same compile error .

vijayk
  • 2,633
  • 14
  • 38
  • 59

1 Answers1

1

It solved my issue after added my external jar in maven dependency.

Steps :

  1. create libs folder in your project. Right click on project > New > Folder > libs
  2. Put your external jar file in that folder.
  3. Open pom.xml file and add that dependency into your code.

Name of jar : ReleaseVersion.jar

    <dependency>
        <groupId>DealerNestQApiReleaseVersion</groupId>
        <artifactId>DealerNestQApiReleaseVersion</artifactId>
        <scope>system</scope>
        <version>1.1</version>
        <systemPath>${basedir}/libs/DealerNestQApiReleaseVersion.jar</systemPath>
    </dependency>
  1. Add following code in maven.

    <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>

By using this steps I solved my issue.

vijayk
  • 2,633
  • 14
  • 38
  • 59