You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "hewguo (GitHub)" <gi...@apache.org> on 2019/02/11 01:07:15 UTC
[GitHub] [incubator-dubbo] hewguo commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
一个最简单的rest例子:
```
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://dubbo.apache.org/schema/dubbo
http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
<dubbo:application name="demo-provider" logger="slf4j"/>
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- use dubbo protocol to export service on port 20880 -->
<dubbo:protocol name="dubbo" port="20880"/>
<dubbo:protocol name="rest" port="8080" server="tomcat" />
<bean id="demoService" class="com.nbport.dubbo.rest.ServiceImpl"/>
<!-- declare the service interface to be exported -->
<dubbo:service interface="com.nbport.dubbo.rest.ServiceFacade" ref="demoService" protocol="rest"/>
</beans>
```
--------
```
@Path("demo")
public class ServiceImpl implements ServiceFacade {
@Override
@Path("hello")
@GET
public String hello() {
return "Hello World! ";
}
@Override
@GET
@Path("/error")
public String error() {
throw new RuntimeException();
}
}
```
使用2.7.0的代码,在浏览器上是访问不到http://localhost:8080/demo/hello页面的,而用2.6.5的代码是可以的。代码跟了一下,2.7的代码getContextPath会返回接口的类名,如:“com.nbport.dubbo.rest.ServiceFacade”,而本例中原来版本返回的是“”。
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org