简体   繁体   English

Eclipse 看不到来自目标/生成源的类

[英]Eclipse doesn't see classes from target/generated-sources

I have a solution with multiple projects(maven parent pom and a couple of child maven projects).我有一个包含多个项目的解决方案(maven 父 pom 和几个子 maven 项目)。 Some of the projects are just a maven project that generates classes from wsdl or xsd using xjc-schema maven plugin.一些项目只是一个 maven 项目,它使用 xjc-schema maven 插件从 wsdl 或 xsd 生成类。 The plugin generates the classes in target/generated-sources folder.该插件在 target/generated-sources 文件夹中生成类。 Now the other projects in the solution has to use the generated classes but eclipse doesn't recognize the generated classes.现在解决方案中的其他项目必须使用生成的类,但 eclipse 无法识别生成的类。

Intellij Idea has no problem with that, it can recognize the generated classes, but I want to use Eclipse. Intellij Idea 没有问题,它可以识别生成的类,但我想使用 Eclipse。

I tried that with Eclipse Neon and Spring Tool Suite based on Neon.我用 Eclipse Neon 和基于 Neon 的 Spring Tool Suite 尝试过。

I tried to refresh, restart etc. with no success.我尝试刷新、重新启动等,但没有成功。 Also tried to add the project with the generated classes to Java Build Path -> Projects of the project that has to use those classes.还尝试将带有生成类的项目添加到必须使用这些类的项目的 Java Build Path -> Projects。

您应该将生成的类的文件夹设为源文件夹。

Also make sure the output folder is correctly set on the java build path.还要确保在 java 构建路径上正确设置了输出文件夹。 If Contains Test Sources is set to Yes , the generated classes will not be detectable from your main classes.如果Contains Test Sources设置为Yes ,则无法从主类中检测到生成的类。

预期的构建路径配置

In case that you are already seeing target/generated-sources/... as a source folder in Eclipse but the IDE is still unaware of the generated classes, go to Configure Build Path... and check that there is no Exclusion Pattern set.如果您已经看到 target/generated-sources/... 作为 Eclipse 中的源文件夹,但 IDE 仍然不知道生成的类,请转到配置构建路径...并检查是否没有设置排除模式. This was causing the problem in my case.这导致了我的问题。

I had a problem with the setting the target/generated-sources as source folder.我在将target/generated-sources为源文件夹时遇到问题。 I had a subfolder with generated classes, and but target/generated-sources set as source folder.我有一个包含生成类的子文件夹,但target/generated-sources设置为源文件夹。 Eclipse didn't read the subfolder, though.但是,Eclipse 没有读取子文件夹。 I removed the target/generated-sources and added the target/generated-sources/<subfolder> and it worked.我删除了target/generated-sources并添加了target/generated-sources/<subfolder>并且它起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从目标/生成源创建包含类的Spring Boot胖JAR - How to create a Spring Boot fat JAR containing classes from target/generated-sources InteliJ 不会在构建时在 target/generated-sources 中创建 OpenAPI 目录,如果手动添加则删除它 - InteliJ doesn't create OpenAPI directory in target/generated-sources on build and deletes it if it's added by hand Maven无法解析在target / generated-sources / javacc文件夹内生成的类的依赖关系 - Maven Not able to resolve dependencies for classes generated inside target/generated-sources/javacc folder 将generated-sources作为源文件夹添加到Eclipse - Add generated-sources as source folder to Eclipse 避免为目标/生成源循环构建项目 - Avoid building project in a loop for target/generated-sources Maven生成的源/注释 - Maven generated-sources/annotations Maven:从jar工件中排除生成的源 - Maven: Exclude generated-sources from jar artifact Lombok 在已编译的 class 中创建获取和设置,但在 Eclipse 中不创建生成源 2020-09 - Lombok creating gets and sets in compiled class but not the generated-sources in Eclipse 2020-09 Fortify在分析中包括生成源 - Fortify includes generated-sources in analysis 将生成的源从代码覆盖范围中排除,而不会影响整个代码覆盖率 - Exclude generated-sources from code coverage without impacting overall code-coverage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM