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

后端 未结 10 1469
名媛妹妹
名媛妹妹 2020-12-14 20:58

You may feel this is a duplicated question, but none of the questions with the same title solve my problems. I am using Jersey 2.0 creating a RESTful web service in Eclipse,

10条回答
  •  青春惊慌失措
    2020-12-14 21:56

    I guess this has already been answered, but just wanted to add an extra tip.

    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.

提交回复
热议问题