我正在编写springboot以与cordaapp集成并使用gradle构建。我想在springboot中调用CordaRPC。尽管我能够构建,但始终会出现以下错误,
java.lang.ClassNotFoundException: javax.json.JsonValue
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at net.corda.nodeapi.ArtemisTcpTransport$Companion.tcpTransport(ArtemisTcpTransport.kt:84)
at net.corda.nodeapi.ArtemisTcpTransport$Companion.tcpTransport$default(ArtemisTcpTransport.kt:44)
at net.corda.client.rpc.CordaRPCClient.<init>(CordaRPCClient.kt:108)
at net.corda.client.rpc.CordaRPCClient.<init>(CordaRPCClient.kt:83)
at net.corda.client.rpc.CordaRPCClient.<init>(CordaRPCClient.kt:83)
at net.corda.client.rpc.CordaRPCClient.<init>(CordaRPCClient.kt)
该行
CordaRPCClient rpcClient = new CordaRPCClient(rpcAddress);
build.gradle文件的片段,
... apply plugin: 'java' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'net.corda.plugins.cordapp' apply plugin: 'net.corda.plugins.cordformation' apply plugin: 'net.corda.plugins.quasar-utils' ... dependencies {
testCompile "junit:junit:$junit_version"
// Corda integration dependencies
cordaCompile "$corda_release_group:corda-core:$corda_release_version"
cordaCompile "$corda_release_group:corda-finance:$corda_release_version"
cordaCompile "$corda_release_group:corda-jackson:$corda_release_version"
cordaCompile "$corda_release_group:corda-rpc:$corda_release_version"
cordaCompile "$corda_release_group:corda-webserver-impl:$corda_release_version"
cordaRuntime "$corda_release_group:corda:$corda_release_version"
cordaRuntime "$corda_release_group:corda-webserver:$corda_release_version"
testCompile "$corda_release_group:corda-node-driver:$corda_release_version"
// CorDapp dependencies
// Specify your cordapp's dependencies below, including dependent CorDapps
cordapp "$corda_release_group:corda-finance:$corda_release_version"
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.11.0'
// implementation 'org.springframework.boot:spring-boot-starter-data-jpa' // implementation 'org.springframework.boot:spring-boot-starter-jersey'
implementation ('org.springframework.boot:spring-boot-starter-web', {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
exclude group: 'org.springframework.boot', module: 'logback-classic'
}
)
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation files('<path to my cordapp jar>')
} ...
答案 0 :(得分:1)
添加依赖项
group='javax.json', module='javax.json-api', version='1.1.4'
答案 1 :(得分:0)
实际问题是apply plugin: 'io.spring.dependency-management'
。
这将org.apache.activemq:artemis-core-client
从2.6.2
撞到2.6.4
丢失的地方org.apache.geronimo.specs:geronimo-json_1.0_spec:1.0-alpha-1
。
如果删除spring插件,一切将再次起作用。
尽管Spring Initializr生成了什么,但您只需要
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
,您可以安全地删除apply plugin: 'io.spring.dependency-management'