首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >原因: java.lang.ClassNotFoundException: javax.servlet.ServletException

原因: java.lang.ClassNotFoundException: javax.servlet.ServletException
EN

Stack Overflow用户
提问于 2018-07-12 18:01:39
回答 0查看 2.1K关注 0票数 0

当我尝试使用Spring-Boot-Test在Spring-boot version1.5.3中运行控制器测试时,我得到了由以下原因引起的错误: java.lang.ClassNotFoundException: javax.servlet.ServletException

代码语言:javascript
复制
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit4.SpringRunner;

import com.hanselnpetal.domain.CustomerContact;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
public class ContactsManagementControllerIntegrationTest {

    @Autowired
    ContactsManagementController contactsManagementController;

    @Test
    public void testAddContactHappyPath() {

        CustomerContact aContact = new CustomerContact();
        aContact.setFirstName("Jenny");
        aContact.setLastName("Johnson");

        // POST our CustomerContact form bean to the controller; check the outcome
        String outcome = contactsManagementController.processAddContactSubmit(aContact);

        // Assert THAT the outcome is as expected
        assertThat(outcome, is(equalTo("success")));
    }


}

我正在使用(eclipse)运行类ContactsManagementControllerIntegrationTest.java,在文件上单击鼠标右键,然后以junit的身份运行。感谢您的帮助。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51302682

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档