我正在尝试使用jersey,Spring boot 1.4和Spring数据jpa编写集成测试。我能够启动嵌入式服务器但是从泽西方面得到错误,任何帮助都将不胜感激。
整合测试
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT, classes=Application.class)
public class ContactServiceIT {
@Autowired
private TestRestTemplate restTemplate;
@Autowired
private ContactDao contactDao;
@Test
public void mergeContactsTest() {
String body = this.restTemplate.getForObject("/contacts/merge", String.class);
assertThat(body).isEqualTo("contacts merged");
}
}
联系资源
import java.io.IOException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import org.springframework.beans.factory.annotation.Autowired;
@Path("/contacts")
public class ContactResource {
@Autowired
private ContactService contactService;
@GET
@Path("merge")
public Response mergeContacts() throws IOException {
contactService.mergeContacts();
return Response.status(Response.Status.CREATED)
.entity("contacts merged").build();
}
}
堆栈追踪:
java.lang.NoSuchMethodError:org.glassfish.jersey.CommonProperties.getValue(Ljava / util / Map; Ljavax / ws / rs / RuntimeType; Ljava / lang / String; Ljava / lang / Object; Ljava / lang / Class ;)Ljava /郎/对象; 在org.glassfish.jersey.jackson.JacksonFeature.configure(JacksonFeature.java:73)〜[jersey-media-json-jackson-2.23.1.jar:na] 在org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:680)~ [jersey-common-2.7.jar:na] 在org.glassfish.jersey.model.internal.CommonConfig.configureMetaProviders(CommonConfig.java:610)~ [jersey-common-2.7.jar:na] 在org.glassfish.jersey.server.ResourceConfig.configureMetaProviders(ResourceConfig.java:800)〜[jersey-server-2.7.jar:na]
如果我错过了什么,请告诉我。
感谢。