[英]Error at compilation by Maven of the Spring Petclinic project
I downloaded the Spring Petclinic project from https://github.com/spring-projects/spring-petclinic/ 我从https://github.com/spring-projects/spring-petclinic/下载了Spring Petclinic项目
The Eclipse compilation works fine – I could run the project from Tomcat. Eclipse编译正常-我可以从Tomcat运行该项目。 However at maven compilation with the same JDK jdk1.6.0_45 got the error:
但是在使用相同的JDK jdk1.6.0_45进行maven编译时出现错误:
org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder required: java.lang.Object.
所需的org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder:java.lang.Object。 The full error is as follows:
完整错误如下:
[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /spring-petclinic/src/test/java/org/springframework/samples/petclinic/web/VisitsViewTests.java:[58,58] \\spring-petclinic\\src\\test\\java\\org\\springframework\\samples\\petclinic\\web\\VisitsViewTests.java:58:
[错误]编译错误:[信息] ----------------------------------------- -------------------- [错误] /spring-petclinic/src/test/java/org/springframework/samples/petclinic/web/VisitsViewTests.java:[58 ,58] \\ spring-petclinic \\ src \\ test \\ java \\ org \\ springframework \\ samples \\ petclinic \\ web \\ VisitsViewTests.java:58:
incompatible types;
不兼容的类型; inferred type argument(s) java.lang.Object do not conform to bounds of type variable(s) B found : org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder required: java.lang.Object
推断的类型参数java.lang.Object不符合类型变量B的范围B:找到的org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder必需:java.lang.Object
Running with debug output got the following error in the very beginning: 一开始使用debug输出运行时会遇到以下错误:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J:无法加载类“ org.slf4j.impl.StaticLoggerBinder”。
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J:默认为无操作(NOP)记录器实现
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
SLF4J:有关更多详细信息,请参见http://www.slf4j.org/codes.html#StaticLoggerBinder 。
The code for the VisitsViewTests is as follows: VisitsViewTests的代码如下:
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration("VisitsViewTests-config.xml")
@ActiveProfiles("jdbc")
public class VisitsViewTests {
@Autowired
private WebApplicationContext webApplicationContext;
private MockMvc mockMvc;
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();
}
@Test
public void getVisitsXml() throws Exception {
ResultActions actions = this.mockMvc.perform(get("/vets.xml").accept(MediaType.APPLICATION_XML));
actions.andDo(print()); // action is logged into the console
actions.andExpect(status().isOk());
actions.andExpect(content().contentType("application/xml"));
actions.andExpect(xpath("/vets/vetList[id=1] /firstName").string(containsString("James")));
}
}
Based on the comment I changed the Spring version in the pom.xml, pointing to 4.0.1. 根据注释,我在pom.xml中更改了Spring版本,使其指向4.0.1。 instead of 4.0.0.
而不是4.0.0。
<spring-framework.version>4.0.1.RELEASE</spring-framework.version>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.