failed to integrate with spring
I tried the examples in the doc to embed jsonrpc4j into spring but I always get 404. I also followed some examples provided by some one in github but it still doesn't work.
It seems to be spring's problem. I googled a lot for this and tried many ways but still could not make it.
So sad.
this is my package:
- com.web
SpringApplication.java
- controller userService.java userServiceImpl.java
the SpringApplication.java
package com.web;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}
the userService.java
package com.web.controller;
import com.web.beans.Block;
import com.googlecode.jsonrpc4j.JsonRpcService;
@JsonRpcService("/user")
public interface userService {
Block getNowBlock();
}
the userServiceImpl.java
package com.web.controller;
import com.web.beans.Block;
import com.googlecode.jsonrpc4j.spring.AutoJsonRpcServiceImpl;
@AutoJsonRpcServiceImpl
public class userServiceImpl implements userService {
@Override
public Block getNowBlock() {
return new Block();
}
}
the beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<bean class="com.googlecode.jsonrpc4j.spring.AutoJsonRpcServiceImplExporter"/>
<bean class="com.web.controller.userServiceImpl" />
</beans>
this is what I get:
array (
'timestamp' => 1529058516280,
'status' => 404,
'error' => 'Not Found',
'message' => 'No message available',
'path' => '/user',
)
I give up using jsonrpc but I will leave the problem here for discussion.
Maybe you could push your code into a github repo, then we can reproduce the problem。 you can try this repo. https://github.com/gshine/exampleofjsonrpc4j