简体   繁体   中英

How to exclude some dependency in maven-compiler-plugin?

Guys I need to find out some way to include or exclude dependency while compile my code in maven (maven-compiler-plugin), I don't want to include all dependency in my class path, just few of them which will be used by java class file to be compile.

Is there any to do this ?

You need to set the scope of the dependency to provided. This will make maven assume that the dependencies will be available at run-time. eg

<dependency>
  <groupId>group-a</groupId>
  <artifactId>artifact-b</artifactId>
  <version>1.0</version>
  <scope>provided</scope>
</dependency>

It is explained much better here -

Dependency scope

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM