Getting a whole lot of “scanned from multiple locations” warnings in simple Jersey web app

血红的双手。 提交于 2019-12-04 02:44:36

There are duplicates in there. Jersey is known for repackaging classes in it's own jars because of OSGI. Which sucks if you don't use and understand OSGI like me. I don't know all of them but for example javax.inject-1 and javax.inject-2.5.0-b42 are the same. Most people use maven which is a better way to manage dependencies (but a steep learning curve to get into) and then would exclude the repackaged one from jersey like:

   <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <exclusions>
            <exclusion><!-- Exclude this repackaged javax.inject. -->
                <groupId>org.glassfish.hk2.external</groupId>
                <artifactId>javax.inject</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.inject</groupId>
        <artifactId>jersey-hk2</artifactId>
        <exclusions>
            <exclusion><!-- Exclude this repackaged javax.inject. -->
                <groupId>org.glassfish.hk2.external</groupId>
                <artifactId>javax.inject</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

But in your case just try to remove javax.inject-2.5.0-b42 and see if you get no more warnings for these classes:

You'll have to figure out the duplicates for the other warnings too. For me it was a little easier because I used maven and the dependency graph in netbeans to find duplicates. Hope this didn't ruin your return to Java.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!