以以下这段代码为例
@Grab('org.jsoup:jsoup:1.10.1')
import org.jsoup.Jsoup
Jsoup.connect('https://v2ex.com').get()
.select('span.item_title > a').each {
println it.text() + ':' + 'https://v2ex.com' + it.attr('href')
}
原本是 groovy2.5+java8,可以正常跑,然后我前两天格盘重装了 mojave,直接上了 Java10,就不行了,报以下错
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/usr/local/Cellar/groovy/2.5.0/libexec/lib/groovy-2.5.0.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Caught: java.lang.NoClassDefFoundError: Unable to load class groovy.xml.jaxb.JaxbGroovyMethods due to missing dependency javax/xml/bind/Unmarshaller
java.lang.NoClassDefFoundError: Unable to load class groovy.xml.jaxb.JaxbGroovyMethods due to missing dependency javax/xml/bind/Unmarshaller
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
谷歌,爆栈网都翻了一番,还是没有找到解决方法,哪位大佬指点迷津?
1
orangeade 2018-07-06 10:51:20 +08:00
Java 8,Java9 还不是 LTS 吧
|
2
unlimitedsola 2018-07-06 10:51:20 +08:00 via Android
|
3
orangeade 2018-07-06 10:51:36 +08:00
说错,Java9,Java10
|
4
unlimitedsola 2018-07-06 10:52:17 +08:00 via Android
上面发的不是最新版 我随便点的一个
|
5
ivyxjc 2018-07-06 10:52:27 +08:00 via Android
stackoverflow 43574426
|
6
hcymk2 2018-07-06 10:53:03 +08:00
|
7
Cbdy OP |
9
Cbdy OP @hcymk2 这个方法我在 stackoverflow 上看到了,是可行但是 quick and dirty 的方法,java11 把 module 移除之后还是跑不了😳,有没有一劳永逸的方法呢?
|
10
beny2mor 2018-07-06 11:19:15 +08:00
Java9 和 Java10 都没有碰过,我们老大说先别管 Jva8 用着先
|
11
blindpirate 2018-07-06 11:54:26 +08:00 via iPhone
add-module java.xml.bind 把 java.xml.bind 加到 root modules 里
|
12
rffan 2018-07-06 16:12:58 +08:00 1
--add-modules=ALL-SYSTEM 我直接这么干的,简单粗暴。。。
|