我知道这个主题已在其他地方的网站上多次询问过。我已经进行了尽职调查,以确保已经尝试过以前类似问题的解决方案。但我仍然无法使其发挥作用。我遇到的问题是:我无法使用Eclipse中的maven(安装了M2E的霓虹灯版本)从avro架构生成源代码。当我尝试" mvn clean generate-sources"或者" mvn clean compile",mvn结果成功,但目标目录中没有生成源代码。
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-avro10 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-avro10 ---
[INFO] Deleting C:\EclipseWS_forOlderProjects\maven-avro10\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.101 s
[INFO] Finished at: 2018-02-18T20:25:46-05:00
[INFO] Final Memory: 8M/241M
[INFO] ------------------------------------------------------------------------
这是我的pom.xml文件
<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>Maven-Avro</groupId>
<artifactId>maven-avro10</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>maven-avro10</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.basedir>C:\EclipseWS_forOlderProjects\maven-avro10</project.basedir>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-tools</artifactId>
<version>1.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-compiler</artifactId>
<version>1.8.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.8.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}\src\main\avro\</sourceDirectory>
<outputDirectory>${project.basedir}\src\main\java\</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
我尝试使用自己的avro架构定义以及Apache Avro入门站点的定义。例如,我将两个avsc文件放在$ {project.basedir} \ src \ main \ avro \中 user.avsc文件
{"namespace": "Maven_Avro.maven_avro10",
"type": "record",
"name": "User",
"fields": [
{"name": "name", "type": "string"},
{"name": "favorite_number", "type": ["int", "null"]},
{"name": "favorite_color", "type": ["string", "null"]}
]
}
和user1.avsc
{"namespace": "example.avro",
"type": "record",
"name": "User1",
"fields": [
{"name": "name", "type": "string"},
{"name": "favorite_number", "type": ["int", "null"]},
{"name": "favorite_color", "type": ["string", "null"]}
]
}
作为我之前阅读的帖子之一,在提到命名空间是他无法生成源代码的问题之前,遗憾的是该帖子没有解释命名空间如何导致问题以及如何更改模式中的命名空间解决了问题。 我已尝试通过&#34; maven-&gt;更新Eclipse项目更新项目...&#34;,我还尝试使用&#34; mvn generate-sources&#34;手动在Eclipse之外构建它。或者&#34; mvn clean generate-sources&#34;,命令行构建都是成功的,但是目标目录或任何其他文件夹中都没有生成源代码。
请让我知道我错过了什么或做错了所以我的Eclipse(或命令行)mvn build不生成avro架构java源代码。提前谢谢。
答案 0 :(得分:1)
您已在不正确的元素this.userService.getUsers().subscribe(users => {
this.pageUsers = users;
});
下配置了插件,请删除此元素并将插件放在<pluginManagement></pluginManagement>
元素下。