运行失败:Error during artifact deployment. See server log for details.

运行失败:Error during artifact deployment. See server log for details.

老师您好,我在写好代码后进行运行,控制台中出现了如下提示:


https://img1.sycdn.imooc.com//climg/616d395d0998bc7f10000180.jpg

我的项目结构:

https://img1.sycdn.imooc.com//climg/616d39a809f56f3206950865.jpg

https://img1.sycdn.imooc.com//climg/616d39b609cbf50b06940870.jpg

相关代码:News实体类

package com.lin.ajax.entity;

public class News {
    private String title;
    private String date;
    private String sourse;
    private String content;

    public News(String title, String date, String sourse, String content) {
        this.title = title;
        this.date = date;
        this.sourse = sourse;
        this.content = content;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getSourse() {
        return sourse;
    }

    public void setSourse(String sourse) {
        this.sourse = sourse;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }
}


相关代码:

NewsServlet类
package com.lin.ajax.servlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.lin.ajax.entity.News;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/news")
public class NewsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<News> list=new ArrayList<>();
        list.add(new News("TIOBE:2018年编程语言排行趋势","2018-5-1","TIOBE","......"));
        list.add(new News("TIOBE:2019年编程语言排行趋势","2018-5-1","TIOBE","......"));
        list.add(new News("TIOBE:2020年编程语言排行趋势","2018-5-1","TIOBE","......"));
        list.add(new News("TIOBE:2012年编程语言排行趋势","2018-5-1","TIOBE","......"));
        //这个类是由Json提供的,用来将对象转为Json字符串的
        ObjectMapper objectMapper=new ObjectMapper();
        String json=objectMapper.writeValueAsString(list);
        response.setContentType("text/json;charset=utf-8");
        response.getWriter().println(json);
    }
}


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕小尤 2021-10-18 17:36:14

同学你好,1、建议同学将out目录设置为Excluded,如下所示:然后删除out与target目录,重新运行项目试一下

https://img1.sycdn.imooc.com//climg/616d3eed090db8db02240203.jpg

https://img1.sycdn.imooc.com//climg/616d3faf09aa177110000829.jpg

2、如果还存在问题,则建议同学查看日志信息,查看具体的异常信息。如下所示:

https://img1.sycdn.imooc.com//climg/616d3ec4092ba47c09470205.jpg

祝学习愉快!

  • 提问者 赵林0225 #1

    老师你就是我的神

    2021-10-18 18:54:12
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师