【发布时间】:2022-01-22 01:41:25
【问题描述】:
通常与Background scanning of projects 相关的人抱怨在启动NetBeans 时会发生这种情况。
我有一个Spring Boot 2.6.x 和Maven 3.8.2 项目,使用Cisco AXL Schema 12.5。
使用Apache CXF从这个AXL Schema生成很多Java源代码文件。
当我之后在我的项目上执行Clean and Build 时,Background scanning of projects 立即启动。
而且最近大部分时间都需要很长时间。
例如,我看到它也扫描
netbeans-12.6/webcommon/jsstubs/corestubs.zip
为什么在构建我的项目时它也要扫描这个?
但大多数时候,虽然它显示 100% 扫描完成,但它花费在生成的 Java 源代码文件所在的文件夹中
<project folder>/target/generated/cxf
生成的Java源代码文件有2282个。
我不确定NetBeans 是否挂起或真的扫描这些文件,它显示 100% 扫描,所以应该完成。
通常需要很长时间,所以我必须从控制台终止NetBeans。 NetBeans 重新启动后,Background scanning for projects 会启动并花费更短的时间,但这很烦人。
我该怎么办?
当我从控制台启动NetBeans 时,我只做./netbeans。以sudo ./netbeans开头NetBeans有区别吗?
这是我的项目文件夹/文件结构的样子,也许我没有正确使用:
首先我提取了src文件夹旁边的AXL Schema
<project folder>
-> schema
-> 12.5
AXLAPI.wsdl
AXLEnums.xsd
AXLSoap.xsd
-> src
-> main/...
-> test/...
在pom.xml我使用
...
<build>
...
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.4.5</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/schema/12.5/AXLAPI.wsdl</wsdl>
<wsdlLocation>classpath:schema/12.5/AXLAPI.wsdl</wsdlLocation>
<extraargs></extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
...
<resources>
...
<resource>
<directory>./</directory>
<includes>
<include>schema/**</include>
</includes>
</resource>
<resource>
<directory>target/generated/cxf</directory>
<includes>
<include>**/*.java</include>
</includes>
</resource>
...
</resources>
</build>
...
也许这个pom.xml 设置不正确,这就是Background scanning for projects 工作错误的原因。
当我在构建后查看生成的 war 文件时,我看到了
WEB-INF
-> classes
-> com/cisco/axl/api/_12
-> schema/12.5
还有一些可能不属于那里的工件。
例如在com/cisco/axl/api/_12 中不仅有class 文件,还有所有相关生成的Java 源代码文件(全部为2282)。
也许schema/12.5 也不应该在war 文件中。
【问题讨论】:
-
<resource><directory>target/generated/cxf</directory>有“味道”!你想达到什么目的? (用这个...在项目资源管理器中浏览生成的源代码!?..请尝试默认值(cxf-output-folder...) -
<resource><directory>./</directory>也不是设计的/对 netbeans 不好 -
NetBeans 抱怨找不到生成的Java源文件,所以我用
解决了.在我将它添加到 pom.xml 之后,NetBeans 中没有错误。target/generated/cxf ... -
能否请您为 pom.xml 提供一些代码 sn-p 的答案,我不知道如何更改它。首先必须生成 AXL Java 源代码文件,为此指定了
,生成这些文件的文件夹是 ${project.build.directory}/generated/cxf 。但是当我尝试使用其中一个生成的 Java 源代码文件时,例如 RPhone.java,NetBeans 并不知道。
标签: spring-boot netbeans cxf maven-3 cisco-axl