解决NetBeans打开Maven工程耗时过长的问题

解决方法:修改配置文件,在netbeans_default_options后添加参数值-J-Dnb.FileChooser.useShellFolder=false,再重启NetBean。

上述方法不是针对maven工程打开慢的解决办法。打开maven工程慢,不只是Netbeans有这个问题,连占用更多内存的Intellij IDEA也有这个问题,问题不是在IDE,而在Maven。

Netbeans是这样说这个问题的。

Repository Indexing allows NetBeans to provide features like editor hints for artifact version upgrades, auto completion for GAV values, actions which add the right dependency for a given class name, search queries and more.

For this to work, NetBeans has to index your local maven repository and optionally download index files of remote repositories.

Please note that this requires some extra storage for the index located in the NetBeans cache directory and some time to asynchronously scan and recompute the index periodically.

大意是 NetBeans IDE的自动提示功能需要索Maven依赖的API。

那么它索引放在哪里呢?这在这里C:\Users\张三\AppData\Local\NetBeans\Cache\20

有mavencachedirs和mavenindex两个目录。

在打开Maven工程时慢,可能在重建索引,或是在加载Maven依赖。 NetBeans自带的Maven使用的Repository是国外的,自然会影响NetBeans重建索引的速度,进而影响打开Mavan工程的速度。

好在NetBeans可以配置Maven,那么这个问题可以解决,或得到优化。

第一步:在netbeans\java\maven\conf\settings.xml配置国内Repository镜像

<mirror>
	<id>alimaven</id>
	<mirrorOf>central</mirrorOf>
	<name>阿里云公共仓库</name>
	<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>

<mirror>
	<id>nexus-aliyun</id>
	<mirrorOf>*</mirrorOf>
	<name>阿里云nexus</name>
	<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>

<mirror>  
	<id>jboss-public-repository-group</id>  
	<mirrorOf>central</mirrorOf>  
	<name>JBoss Public Repository Group</name>  
	<url>http://repository.jboss.org/nexus/content/groups/public</url>  
</mirror>

配置多个镜像,有后备力量保障。

第二步:在Maven索引策略这块,勾选上索引时使用多线程,加块速度;检查更新改为每周一次,避免频繁检查。

第三步:配置本地配置的Repository,避免索引时从网络上取依赖包。

需要在在netbeans\java\maven\conf\settings.xml添加配置,指定localRepository地址。

  <localRepository>D:\apps\apache-maven-3.9.9\repository</localRepository>

配置这些后,不要想着打开Mavean工程立马有效果,NetBeans仍然要创建索引,创建索引需要时间,这些办法只是解决了NetBeans索引时快速获得需要的依赖,但是速度几乎是秒开。

  • 25
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值