You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/nosql/migrate-java-v4-sdk.md
+73Lines changed: 73 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -111,6 +111,79 @@ Azure Cosmos DB Java SDK 4.0 exposes `get` and `set` methods to access the insta
111
111
112
112
This is different from Azure Cosmos DB Java SDK 3.x.x which exposes a fluent interface. For example, a `CosmosSyncContainer` instance has `container.id()` which is overloaded to get or set the `id` value.
113
113
114
+
### Managing Dependency Conflicts
115
+
116
+
Upgrading from Azure Cosmos DB Java SDK V2 to V4 can introduce dependency conflicts due to changes in the libraries used by the SDK. Resolving these conflicts requires careful management of the dependencies.
117
+
118
+
1.**Understand the New Dependencies**: The Azure Cosmos DB V4 SDK has its own set of dependencies that might be different from those in prior versions. Make sure you are aware of these dependencies:
119
+
120
+
-`azure-cosmos`
121
+
-`reactor-core`
122
+
-`reactor-netty`
123
+
-`netty-handler`
124
+
-`guava`
125
+
-`slf4j-api`
126
+
-`jackson-databind`
127
+
-`jackson-annotations`
128
+
-`jackson-core`
129
+
-`commons-lang3`
130
+
-`commons-collections4`
131
+
-`azure-core`
132
+
-`azure-core-http-netty`
133
+
134
+
2.**Remove Conflicting Dependencies**: Start by removing the dependencies related to prior versions of the SDK from your `pom.xml` file. These include `azure-cosmosdb` and any transitive dependencies that the old SDK might have had.
135
+
136
+
3.**Add V4 SDK Dependencies**: Add the V4 SDK and its dependencies to your `pom.xml`. Here's an example:
137
+
138
+
```xml
139
+
<dependency>
140
+
<groupId>com.azure</groupId>
141
+
<artifactId>azure-cosmos</artifactId>
142
+
<version>4.x.x</version> <!-- Use the latest version available -->
143
+
</dependency>
144
+
```
145
+
146
+
4.**Check for Dependency Conflicts**: Use the Maven `dependency:tree` command to generate a dependency tree and identify any conflicts. Run:
147
+
148
+
```shell
149
+
mvn dependency:tree
150
+
```
151
+
152
+
Look for any conflicting versions of dependencies. These conflicts often occur with libraries like `reactor-core`, `netty-handler`, `guava`, and `jackson`.
153
+
154
+
5.**Use Dependency Management**: If you encounter version conflicts, you might need to override problematic versions using the `<dependencyManagement>` section in your `pom.xml`. Here’s an example to enforce a specific version of `reactor-core`:
155
+
156
+
```xml
157
+
<dependencyManagement>
158
+
<dependencies>
159
+
<dependency>
160
+
<groupId>io.projectreactor</groupId>
161
+
<artifactId>reactor-core</artifactId>
162
+
<version>3.x.x</version> <!-- Use a compatible version -->
163
+
</dependency>
164
+
<!-- Repeat for any other conflicting dependencies -->
165
+
</dependencies>
166
+
</dependencyManagement>
167
+
```
168
+
169
+
6.**Exclude Transitive Dependencies**: Sometimes, you may need to exclude transitive dependencies brought in by other dependencies. For instance, if another library brings in an older version of a dependency that conflicts, you can exclude it like this:
170
+
171
+
```xml
172
+
<dependency>
173
+
<groupId>some.group</groupId>
174
+
<artifactId>some-artifact</artifactId>
175
+
<version>x.x.x</version>
176
+
<exclusions>
177
+
<exclusion>
178
+
<groupId>conflicting.group</groupId>
179
+
<artifactId>conflicting-artifact</artifactId>
180
+
</exclusion>
181
+
</exclusions>
182
+
</dependency>
183
+
```
184
+
185
+
7.**Rebuild and Test**: After making these changes, rebuild your project and thoroughly test it to ensure that the new dependencies work correctly and that no runtime conflicts occur.
0 commit comments