Java Vertx服务代理编译错误无法解析为类型

Java Vertx服务代理编译错误无法解析为类型,java,proxy,vert.x,vertx-verticle,vertx-eventbus,Java,Proxy,Vert.x,Vertx Verticle,Vertx Eventbus,我正在使用vertx服务代理。当我尝试添加所有必需的依赖项和包信息java文件时。我仍然无法将vertx编译错误解析为类型。从教程中我了解到这是一个生成的文件,但它不会生成 pom.xml如下所示: <modelVersion>4.0.0</modelVersion> <groupId>io.vertx.starter</groupId> <artifactId>vertx-start-project</artifactId>

我正在使用vertx服务代理。当我尝试添加所有必需的依赖项和包信息java文件时。我仍然无法将vertx编译错误解析为类型。从教程中我了解到这是一个生成的文件,但它不会生成

pom.xml如下所示:

<modelVersion>4.0.0</modelVersion>
<groupId>io.vertx.starter</groupId>
<artifactId>vertx-start-project</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<vertx.version>3.8.3</vertx.version>
<main.verticle>io.vertx.starter.MainVerticle</main.verticle>
</properties>

<dependencyManagement>
<dependencies>
  <dependency>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-stack-depchain</artifactId>
    <version>${vertx.version}</version>
    <type>pom</type>
    <scope>import</scope>
  </dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-core</artifactId>
</dependency>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.12</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-unit</artifactId>
  <scope>test</scope>
</dependency>
<dependency>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-web</artifactId>
</dependency>
<dependency>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-web-templ-freemarker</artifactId>
</dependency>
<dependency>
    <groupId>com.github.rjeschke</groupId>
    <artifactId>txtmark</artifactId>
    <version>0.13</version>
</dependency>
<dependency>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-jdbc-client</artifactId>
</dependency>
<dependency>
    <groupId>org.hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <version>2.3.4</version>
</dependency>
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.2.3</version>
</dependency>   
<dependency>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-service-proxy</artifactId>
</dependency>
<dependency>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-codegen</artifactId>
    <scope>provided</scope>
   </dependency>
  </dependencies>

 <build>
<pluginManagement>
  <plugins>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.5.1</version>
      <configuration>
        <source>1.8</source>
        <target>1.8</target>

        <annotationProcessors>
        <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
        </annotationProcessors>
        <generatedSourcesDirectory>${project.basedir}/src/main/generated</generatedSourcesDirectory>
        <compilerArgs>
            <arg>-AoutputDirectory=${project.basedir}/src/main</arg>
        </compilerArgs>
      </configuration>
    </plugin>
    <!-- tag::clean[] -->
    <plugin>
      <artifactId>maven-clean-plugin</artifactId>
      <version>3.0.0</version>
      <configuration>
        <filesets>
          <fileset>
            <directory>${project.basedir}/src/main/generated</directory>
          </fileset>
        </filesets>
      </configuration>
    </plugin>
    <!-- end::clean[] -->
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-deploy-plugin</artifactId>
      <version>2.8.2</version>
      <configuration>
        <skip>true</skip>
      </configuration>
    </plugin>
    </plugins>
</pluginManagement>

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4.3</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <manifestEntries>
                <Main-Class>io.vertx.core.Launcher</Main-Class>
                <Main-Verticle>${main.verticle}</Main-Verticle>
              </manifestEntries>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
              <resource>META-INF/services/io.vertx.core.spi.VerticleFactory</resource>
            </transformer>
          </transformers>
          <artifactSet>
          </artifactSet>
          <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
        </configuration>
      </execution>
    </executions>
  </plugin>

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.5.0</version>
    <configuration>
      <mainClass>io.vertx.core.Launcher</mainClass>
      <arguments>
        <argument>run</argument>
        <argument>${main.verticle}</argument>
      </arguments>
    </configuration>
  </plugin>
</plugins>

如果您使用Eclipse作为IDE来开发使用服务代理的Vert.X项目,那么您还需要做一些事情来生成代码:

1) 在WikiDatabaseService界面中注释以下行:

@GenIgnore
static WikiDatabaseService createProxy(Vertx vertx, String address) {
return new WikiDatabaseServiceVertxEBProxy(vertx, address);
}
2) 右键单击project Explorer中的Vert.X项目,选择生成路径>配置生成路径
2.1)选择源选项卡(确保在左侧栏中选择了Java构建路径)
2.2)单击添加文件夹 2.3)确保选中src/main/
下的生成的文件夹 2.4)单击确定,然后应用/应用并关闭
3) 在Vert.X项目文件夹内的terminal/cmd(取决于您使用的操作系统)中,执行以下命令:mvn clean package->执行此命令是必要的,因为需要为代理类执行代码生成,以便代码能够正常工作。
4) 取消步骤1)中的代码注释,然后再次运行mvn clean package命令
5) 通过执行
java-jar./target/name\u of_project-fat.jar
(在您的情况下,它应该是
java-jar./target/vertx start project fat.jar
sh./redeploy.sh
(Linux上的

原因是Eclipse与IntellIJ IDEA不同,它并没有按照其声明的那样在类路径下拾取生成的文件夹:

注意,生成的代码放在src/main/generated中,其中 像IntelliJ IDEA这样的集成开发环境将 在类路径上自动拾取


希望能有所帮助。

您使用的是Eclipse IDE还是其他非IntellIJ IDEA的IDE?@NikolaS it'seclipse@Jawad_Hassan_Soomro:我的回答有帮助吗?
 @ModuleGen(groupPackage = "io.vertx.starter.database", name = "starter-database")
 package io.vertx.starter.database;

 import io.vertx.codegen.annotations.ModuleGen;
@GenIgnore
static WikiDatabaseService createProxy(Vertx vertx, String address) {
return new WikiDatabaseServiceVertxEBProxy(vertx, address);
}