I'm having some problems with conflicting versions of some jars. I have a dependency on a library `group-a:artifact-a:0.0.1` that has a dependency on `group-b:artifact-b:0.0.1`, but I don't want that `group-b:artifact-b:0.0.1` to be included given that I know that at runtime there will be `group-b:artifact-b:0.0.2`.

How do I have to write the `pom.xml` file?

Is this one of the following correct? And what's the difference between these?

**Solution 1:**

Exclude `group-b:artifact-b` from `group-a:artifact-a:0.0.1`:

```
<dependencies>
    <dependency>
        <groupId>group-a</groupId>
        <artifactId>artifact-a</artifactId>
        <version>0.0.1</version>
        <exclusions>
            <exclusion>
                <groupId>group-b</groupId>
                <artifactId>artifact-b</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

```

**Solution 2:**

Add `group-b:artifact-b` dependency as *provided*:

```
<dependencies>
    <dependency>
        <groupId>group-b</groupId>
        <artifactId>artifact-b</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>group-a</groupId>
        <artifactId>artifact-a</artifactId>
        <version>0.0.1</version>
    </dependency>
</dependencies>

```

**Solution 3:**

Add `group-b:artifact-b` dependency as *runtime*:

```
<dependencies>
    <dependency>
        <groupId>group-b</groupId>
        <artifactId>artifact-b</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>group-a</groupId>
        <artifactId>artifact-a</artifactId>
        <version>0.0.1</version>
    </dependency>
</dependencies>

```

**Solution 4:**

Add `group-b:artifact-b` dependency as *provided* or *runtime* and exclude it from `group-a:artifact-a:0.0.1`.

**UPDATE:**
Sorry for not being explicit, but yes @Tunaki's assumption is correct, the dependency `group-b:artifact-b:0.0.2` is not required at compile time.