该帖已经被评为精华帖
|
|
---|---|
作者 | 正文 |
发表时间:2012-03-07
stamen 写道 wensen 写道 是啊,搞成maven project,就没那么大了
呵呵 好的,接下来就改。 因为家里网络慢啊,呵呵,随便弱弱的问下,反射用多了对性能的影响?我看了你里面的代码,有些是用了反射 |
|
返回顶楼 | |
发表时间:2012-03-08
godson_2003 写道 Exception in thread "main" org.springframework.web.client.RestClientException: Cannot extract response: no Content-Type found
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:56) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:352) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:307) at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:234) at UserRestServiceClientTest.main(UserRestServiceClientTest.java:39) 37 form.add("sign", sign); 38 String response = null; 39 response = restTemplate.postForObject("http://localhost:8080/scm", form, String.class); System.out.println("response:\n" + response); org.springframework.web.client.RestClientException: Cannot extract response: no Content-Type found 这个应该指定返回的response的类型 比如 application/json之类的 |
|
返回顶楼 | |
发表时间:2012-03-08
sky_cn 写道 部署成功了为什么我在UserRestService里面打断点,都无法进入
你先把断点放到AnnotationRopServiceRouter的service()中,这是ROP的总入口,如果这个地方都没有进来,要么是web.xml配置的问题(不要改原来的),要么是你URL的问题。 |
|
返回顶楼 | |
发表时间:2012-03-08
最后修改:2012-03-08
找到原因了,因为配置文件
<!--① 扫描Web类包--> <context:component-scan base-package="com.stamen"> <!-- 启用AnnotationRopServiceRouter--> <context:include-filter type="aspectj" expression="com.stamen.rop.impl.AnnotationRopServiceRouter"/> <!-- 假设所有的服务方法都放在rop包下--> <context:include-filter type="aspectj" expression="within(com.stamen.rop.xxx.rop..*)"/> </context:component-scan> 而 package com.sample.rop 是所以导致无法监听到,另外客户端测试写的也有些问题
String response = restTemplate.postForObject( "http://localhost:9080/router", form, String.class); System.out.println("response:\n" + response); 直接写http://localhost:9080/router也是访问不到的,一般部署肯定有个应用的名字比如我的应用叫mvc3应该是String response = restTemplate.postForObject(
"http://localhost:9080/mvc3/router", form, String.class); System.out.println("response:\n" + response); 才可以访问到,另外我已经把楼主的项目变成m2工程了,并添上了jetty插件的集成感觉还不错,呵呵
配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>rop-framework</groupId> <artifactId>rop-framework</artifactId> <version>0.0.1</version> <repositories> <repository> <id>spring-release</id> <name>Spring Maven release Repository</name> <url>http://repo.springsource.org/release</url> </repository> </repositories> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!-- third begin --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-asm</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-instrument</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-instrument-tomcat</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jms</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.6.10</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.0.0.GA</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.1.0.Final</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-all</artifactId> <version>1.9.5</version> </dependency> <!-- --> </dependencies> <build> <finalName>rop-framework</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> <encoding>UTF8</encoding> </configuration> </plugin> </plugins> </build> </project> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>rop-biz</groupId> <artifactId>rop-biz</artifactId> <version>0.0.1</version> <dependencies> <dependency> <groupId>rop-framework</groupId> <artifactId>rop-framework</artifactId> <version>0.0.1</version> </dependency> </dependencies> <build> <finalName>rop-biz</finalName> </build> </project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>rop</groupId> <artifactId>rop</artifactId> <version>0.0.1-SNAPSHOT</version> <dependencies> <dependency> <groupId>rop-web</groupId> <artifactId>rop-web</artifactId> <version>0.0.1</version> </dependency> <dependency> <groupId>rop-biz</groupId> <artifactId>rop-biz</artifactId> <version>0.0.1</version> </dependency> <dependency> <groupId>rop-framework</groupId> <artifactId>rop-framework</artifactId> <version>0.0.1</version> </dependency> <dependency> <groupId>com.ibm</groupId> <artifactId>db2jcc</artifactId> <version>9.5.3</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> <!--scope>provided</scope --> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <scope>provided</scope> <version>2.4</version> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <scope>provided</scope> <version>2.0</version> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-jsp</artifactId> <version>2.0.6</version> </dependency> <dependency> <groupId>com.caucho</groupId> <artifactId>hessian</artifactId> <version>4.0.7</version> </dependency> </dependencies> <build> <plugins> <!-- jetty插件 --> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.5</version> <configuration> <webAppSourceDirectory>src/main/webapp</webAppSourceDirectory> <scanIntervalSeconds>3</scanIntervalSeconds> <contextPath>/mvc3</contextPath> <webDefaultXml>jetty.xml</webDefaultXml> <jettyEnvXml>jetty-env.xml</jettyEnvXml> <connectors> <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> <port>9080</port> </connector> </connectors> </configuration> </plugin> </plugins> </build> </project> mvn工程地址: |
|
返回顶楼 | |
发表时间:2012-03-08
to:sky_cn
哈 不错,你已经把它maven了,强! |
|
返回顶楼 | |
发表时间:2012-03-08
举手之劳而已,在eclipse上有m2插件支持用mvn比较方便,另外感觉单元测试和jetty插件集成也很方便
|
|
返回顶楼 | |
发表时间:2012-03-08
好东西,非常期待能够做大起来。
|
|
返回顶楼 | |
发表时间:2012-03-08
总是报这个警告:warning no match for this type name: within [Xlint:invalidAbsoluteTypeName]
2012-03-08 20:18:47,140 INFO [main] (AbstractHandlerMethodMapping.java:188) - Mapped "{[/sol],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void com.rop.impl.AnnotationRopServiceRouter.test() 2012-03-08 20:18:47,141 INFO [main] (AbstractHandlerMethodMapping.java:188) - Mapped "{[/router],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void com.rop.impl.AnnotationRopServiceRouter.service(org.springframework.web.context.request.WebRequest,javax.servlet.http.HttpServletResponse) 而且里面的没有一个值,不知道怎么回事 访问接口总是显示: -<error solution="服务目前无法使用" message="服务不可用" code="1"> -<subErrors> -<subError> <code>isv.sample-user-add-service-unavailable</code> <message>调用后端服务sample.user.add抛异常,服务不可用</message> </subError> </subErrors> </error> |
|
返回顶楼 | |
发表时间:2012-03-08
运行不起来
不是路径写错,就是。。。 |
|
返回顶楼 | |
发表时间:2012-03-08
谢谢了,正在研究这个,刚好可参考
|
|
返回顶楼 | |