jersey+maven構建restful服務

http://blog.csdn.net/liuchuanhong1/article/details/52880598


(1)若報錯如下:

Failed to read artifact descriptor for org.glassfish.jersey.containers:jersey-container-servlet:jar:2.17

解決方法如下:

I was able to resolve the issue with below steps: Right click on the maven project in Eclipse -> Maven -> Update Project -> Check "Force update of snapshots/Releases" check box.



(2)若報錯如下:

java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer

解決方法如下:

For web projects in Eclipse, it is almost always advisable to manage dependencies with Maven. Use a Maven plugin like m2e. Once you add a dependency to your Maven project, it should automatically deploy those libraries to WEB-INF/lib. If it does not (for whatever reasons), you can explicit do so:

  1. Right-click on your project in Project Explorer
  2. Select Properties
  3. Select Deployment Assembly
  4. If Maven Dependencies is not one of the entries, the libraries were not added automatically, so we'll add them now
  5. Select Add
  6. Select Java Build Path Entries
  7. Select Maven Dependencies
  8. Click Finish

This should add the libraries to WEB-INF/lib, although you'd still not see them in the Project Explorer view. But your ClassNotFoundException should go away now.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章