简体   繁体   中英

cannot find symbol: Package not recognized

I can't get this project compiled, even doing all the necessary configs but unfortunately without success.

I compiled first exchange-core successfully: Using this command:

mvn install

And this is a require dependency for the other project to work.

After that, I got to target folder, and launched this command:

mvn install:install-file -Dfile=exchange-core-0.5.4-SNAPSHOT.jar -DgroupId=exchange.core2 -DartifactId=exchange-core -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar -DgeneratePom=true

So I can make the dependencies accessible for other projects.

But when trying to compile the gateway (the project that will use the first compilation), I am getting this error !

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Exchange REST Gateway 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ exchange-gateway-rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 9 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ exchange-gateway-rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 62 source files to /build/exchange-gateway/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/controllers/SyncTradeMiscApiController.java:[26,33] package org.jetbrains.annotations does not exist
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/RestGatewayApplication.java:[20,37] cannot find symbol
  symbol:   class OrderBookFastImpl
  location: package exchange.core2.core.orderbook
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/RestGatewayApplication.java:[21,50] package exchange.core2.core.processors.journalling do
es not exist
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/RestGatewayApplication.java:[31,52] cannot find symbol
  symbol:   class ThreadAffinityMode
  location: class exchange.core2.core.utils.UnsafeUtils
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/RestGatewayApplication.java:[31,1] static import only from classes and interfaces
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/controllers/SyncTradeMiscApiController.java:[64,6] cannot find symbol
  symbol:   class NotNull
  location: class exchange.core2.rest.controllers.SyncTradeMiscApiController
[INFO] 6 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.359 s
[INFO] Finished at: 2020-07-02T20:13:06Z
[INFO] Final Memory: 35M/85M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project exchange-gateway-rest: Compilation
 failure: Compilation failure:
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/controllers/SyncTradeMiscApiController.java:[26,33] package org.jetbrains.annotations doe
s not exist
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/RestGatewayApplication.java:[20,37] cannot find symbol
[ERROR]   symbol:   class OrderBookFastImpl
[ERROR]   location: package exchange.core2.core.orderbook
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/RestGatewayApplication.java:[21,50] package exchange.core2.core.processors.journalling do
es not exist
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/RestGatewayApplication.java:[31,52] cannot find symbol
[ERROR]   symbol:   class ThreadAffinityMode
[ERROR]   location: class exchange.core2.core.utils.UnsafeUtils
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/RestGatewayApplication.java:[31,1] static import only from classes and interfaces
[ERROR] /build/exchange-gateway/src/main/java/exchange/core2/rest/controllers/SyncTradeMiscApiController.java:[64,6] cannot find symbol
[ERROR]   symbol:   class NotNull
[ERROR]   location: class exchange.core2.rest.controllers.SyncTradeMiscApiController
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

This error:

package org.jetbrains.annotations does not exist

Can be solved by adding jetbrains dependencies I think, or by removing it from the files.

But what about the others like:

cannot find symbol
[ERROR]   symbol:   class OrderBookFastImpl
[ERROR]   location: package exchange.core2.core.orderbook

Knowing that this dependencies are from the first project.

I am using docker with image: maven:3.5.2-jdk-8-alpine

Projects on github

Project 1 (exchange-core): https://github.com/mzheravin/exchange-core

Project 2 (exchange-gateway): https://github.com/exchange-core/exchange-gateway-rest

POM.XML file of the second project:

<?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>exchange.core2</groupId>
    <artifactId>exchange-gateway-rest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Exchange REST Gateway</name>
    <description>Java Exchange Market Gateway</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath/>
    </parent>

    <properties>
        <skip.it>false</skip.it>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>

        <guava.version>25.0-jre</guava.version>
        <commons-math3.version>3.6.1</commons-math3.version>
        <commons-lang3.version>3.7</commons-lang3.version>

        <HikariCP.version>3.1.0</HikariCP.version>

        <eclipse.collections.version>9.2.0</eclipse.collections.version>
    </properties>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${commons-lang3.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-math3</artifactId>
                <version>${commons-math3.version}</version>
            </dependency>

            <!-- Eclipse (Goldman Sachs) collections -->
            <dependency>
                <groupId>org.eclipse.collections</groupId>
                <artifactId>eclipse-collections-api</artifactId>
                <version>9.2.0</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.collections</groupId>
                <artifactId>eclipse-collections</artifactId>
                <version>9.2.0</version>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>exchange.core2</groupId>
            <artifactId>exchange-core</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>sockjs-client</artifactId>
            <version>1.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>stomp-websocket</artifactId>
            <version>2.3.3</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>3.3.7</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.8</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <!-- DATABASE PERSISTENCE -->
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat</groupId>
                    <artifactId>tomcat-jdbc</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-java8</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>${HikariCP.version}</version>
        </dependency>

        <!-- Eclipse (Goldman Sachs) collections -->
        <dependency>
            <groupId>org.eclipse.collections</groupId>
            <artifactId>eclipse-collections-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.collections</groupId>
            <artifactId>eclipse-collections</artifactId>
        </dependency>

        <!-- tests -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>it</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration combine.self="override">
                            <!--<argLine>-XX:+PrintApplicationStoppedTime</argLine>-->
                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
                            <includes>
                                <include>**/IT*.java</include>
                                <include>**/*IntegrationTest.java</include>
                            </includes>
                            <excludes>
                                <exclude>**/remote/**/*.class</exclude>
                                <exclude>**/stress/**/*.class</exclude>
                                <exclude>**/*Remote*Test.java</exclude>
                                <exclude>**/*Stress*Test.java</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

We call local dependency from this lines:

    <dependency>
        <groupId>exchange.core2</groupId>
        <artifactId>exchange-core</artifactId>
        <version>0.5.4-SNAPSHOT</version> //<-- changed the version here to the current one
    </dependency>

Look at this: in mvn install:install-file command you wrote version=0.0.1-SNAPSHOT , whereas in pom.xml I see <version>0.5.4-SNAPSHOT</version> .

I cloned your git repositories.
There is no OrderBookFastImpl class in your exchange-core project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM