无法导入org.springframework.data.rest.webmvc.ResourceNotFoundException;

huangapple go评论83阅读模式
英文:

can't import org.springframework.data.rest.webmvc.ResourceNotFoundException;

问题

我无法提供代码的翻译,但以下是您提供的英文文本的中文翻译:

"我一直无法导入以下库以用于处理一些错误。我一直在互联网上寻找有关这个问题的信息,但没有成功。是不是我需要下载一个特定的.jar文件?如果是这样,我将感谢您告诉我如何做。我对这个网络和Spring的东西还不太了解。"

"代码:"

package org.magnum.dataup;

import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.magnum.dataup.model.Video;
import org.magnum.dataup.model.VideoStatus;
import org.magnum.dataup.model.VideoStatus.VideoState;
import org.eclipse.jetty.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;

@Controller
public class VideoController {

  public static final String VIDEO_SVC_PATH = "/video";
  public static final String VIDEO_DATA_PATH = VIDEO_SVC_PATH + "/{id}/data";
  private static final AtomicLong currentId = new AtomicLong(0L);

  private Map<Long, Video> videos = new HashMap<Long, Video>();

  @RequestMapping(value = VIDEO_SVC_PATH, method = RequestMethod.GET)
  public @ResponseBody Collection<Video> getVideoList() {
    return videos.values();
  }

  @RequestMapping(value = VIDEO_DATA_PATH, method = RequestMethod.GET)
  public void getData(@PathVariable("id") long id, HttpServletResponse response)
      throws IOException {
    VideoFileManager videoData = VideoFileManager.get();

    try {
      videoData.copyVideoData(videos.get(id), response.getOutputStream());
    } catch (Exception e) {
      throw new ResourceNotFoundException();
    }
  }

  @RequestMapping(value = VIDEO_SVC_PATH, method = RequestMethod.POST)
  public @ResponseBody Video addVideoMetadata(@RequestBody Video v, HttpServletRequest request)
      throws IOException {
    v.setId(currentId.incrementAndGet());
    v.setDataUrl(getUrlBaseForLocalServer(request) + "/" + VIDEO_SVC_PATH + v.getId() + "/data");
    videos.put(v.getId(), v);
    return v;
  }

  @RequestMapping(value = VIDEO_DATA_PATH, method = RequestMethod.POST)
  public @ResponseBody VideoStatus addVideoData(@PathVariable("id") long id,
      @RequestParam MultipartFile data) throws IOException {
    VideoFileManager videoData = VideoFileManager.get();
    try {
      videoData.saveVideoData(videos.get(id), data.getInputStream());
    } catch (Exception e) {
      throw new ResourceNotFoundException();
    }
    return new VideoStatus(VideoState.READY);
  }

  private String getUrlBaseForLocalServer(HttpServletRequest request) {
    String baseURL = "http://" + request.getServerName()
        + ((request.getServerPort() != 80) ? ":" + request.getServerPort() : "");
    return baseURL;
  }

}

导入时的错误消息:

无法导入org.springframework.data.rest.webmvc.ResourceNotFoundException;

提前感谢您的帮助。

英文:

I haven not being able to import the following library to use it for handling some error. I have been looking up on internet about this problem but cannot succeed. Is it that i have to download an specific .jar? if so, I would appreciate the help to know how to do it. I am pretty new into this web and spring stuff.

Code:

package org.magnum.dataup;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.magnum.dataup.model.Video;
import org.magnum.dataup.model.VideoStatus;
import org.magnum.dataup.model.VideoStatus.VideoState;
import org.eclipse.jetty.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
@Controller
public class VideoController {
public static final String VIDEO_SVC_PATH = &quot;/video&quot;;
public static final String VIDEO_DATA_PATH = VIDEO_SVC_PATH + &quot;/{id}/data&quot;;
private static final AtomicLong currentId = new AtomicLong(0L);
private Map&lt;Long, Video&gt; videos = new HashMap&lt;Long, Video&gt;();
@RequestMapping(value = VIDEO_SVC_PATH, method = RequestMethod.GET)
public @ResponseBody Collection&lt;Video&gt; getVideoList() {
return videos.values();
}
@RequestMapping(value = VIDEO_DATA_PATH, method = RequestMethod.GET)
public void getData(@PathVariable(&quot;id&quot;) long id, HttpServletResponse response)
throws IOException {
VideoFileManager videoData = VideoFileManager.get();
try {
videoData.copyVideoData(videos.get(id), response.getOutputStream());
} catch (Exception e) {
throw new ResourceNotFoundException();
}
}
@RequestMapping(value = VIDEO_SVC_PATH, method = RequestMethod.POST)
public @ResponseBody Video addVideoMetadata(@RequestBody Video v, HttpServletRequest request)
throws IOException {
v.setId(currentId.incrementAndGet());
v.setDataUrl(getUrlBaseForLocalServer(request) + &quot;/&quot; + VIDEO_SVC_PATH + v.getId() + &quot;/data&quot;);
videos.put(v.getId(), v);
return v;
}
@RequestMapping(value = VIDEO_DATA_PATH, method = RequestMethod.POST)
public @ResponseBody VideoStatus addVideoData(@PathVariable(&quot;id&quot;) long id,
@RequestParam MultipartFile data) throws IOException {
VideoFileManager videoData = VideoFileManager.get();
try {
videoData.saveVideoData(videos.get(id), data.getInputStream());
} catch (Exception e) {
throw new ResourceNotFoundException();
}
return new VideoStatus(VideoState.READY);
}
private String getUrlBaseForLocalServer(HttpServletRequest request) {
String baseURL = &quot;http://&quot; + request.getServerName()
+ ((request.getServerPort() != 80) ? &quot;:&quot; + request.getServerPort() : &quot;&quot;);
return baseURL;
}
}

Error Message when importing:

无法导入org.springframework.data.rest.webmvc.ResourceNotFoundException;

Thanks in advance

答案1

得分: 0

你正在寻找的JAR文件可以从Maven仓库这里获取。

如果您使用Maven进行依赖管理,只需将以下内容添加到您的pom.xml文件中:

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-rest-webmvc</artifactId>
    <version>3.3.3.RELEASE</version>
</dependency>
英文:

The jar you looking for is available from maven repo here .

If you use maven for dependency management just add this to your pom.xml

    &lt;dependency&gt;
&lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
&lt;artifactId&gt;spring-data-rest-webmvc&lt;/artifactId&gt;
&lt;version&gt;3.3.3.RELEASE&lt;/version&gt; 
&lt;/dependency&gt;

huangapple
  • 本文由 发表于 2020年8月14日 05:30:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/63403480.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定