gpt4 book ai didi

java - Spring Petclinic 项目的 Maven 编译出错

转载 作者:太空宇宙 更新时间:2023-11-04 07:05:20 26 4
gpt4 key购买 nike

我从 https://github.com/spring-projects/spring-petclinic/ 下载了 Spring Petclinic 项目

Eclipse 编译工作正常 - 我可以从 Tomcat 运行该项目。但是在使用相同的JDK jdk1.6.0_45进行maven编译时出现错误:

org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder required: 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:

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

使用调试输出运行一开始就出现以下错误:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

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")));
}
}

最佳答案

根据评论,我更改了 pom.xml 中的 Spring 版本,指向 4.0.1。而不是 4.0.0。

<spring-framework.version>4.0.1.RELEASE</spring-framework.version>

关于java - Spring Petclinic 项目的 Maven 编译出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21490521/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com