Local jars are not included in class path (`system`)

后端 未结 5 1249
挽巷
挽巷 2020-12-03 16:11

I am trying to build my application using maven and eclipse. I have dependencies on 3rd party jars which are on my local machine. here is my pom.xml



        
5条回答
  •  Happy的楠姐
    2020-12-03 16:51

    I have not got any thought why it is happening why maven is not including files with system scope to my war file. Please give me any idea how this problem can be resolved.

    This is by design, system scoped dependencies are supposed to be provided as documented.

    Actually, I've written numerous times (here, here, here and here) that system scoped dependencies should be avoided. They are most of time a bad practice, people are abusing them, and they generate almost always more troubles than benefits.

    Let me quote the Dependency Scopes mini guide if you want an "official" point of view:

    • system: This dependency is required in some phase of your project's lifecycle, but is system-specific. Use of this scope is discouraged: This is considered an "advanced" kind of feature and should only be used when you truly understand all the ramifications of its use, which can be extremely hard if not actually impossible to quantify. This scope by definition renders your build non-portable. It may be necessary in certain edge cases. The system scope includes the element which points to the physical location of this dependency on the local machine. It is thus used to refer to some artifact expected to be present on the given local machine an not in a repository; and whose path may vary machine-to-machine. The systemPath element can refer to environment variables in its path: ${JAVA_HOME} for instance.

    So, instead of using the system scope, either:

    • Add your libraries to your local repository via install:install-file. This is a quick and dirty way to get things working, it might be an option if you're alone but it makes your build non portable.
    • Install and run an "enterprise repository" like Nexus, Archiva, or Artifactory and add your libraries via deploy:deploy-file. This is the ideal scenario.
    • Setup a file based repository as described in this previous answer and put your libraries in there. This is the best compromise if you don't have a corporate repository but need to work as a team and don't want to sacrifice portability.

    Please, stop using the system scope.

提交回复
热议问题