|
| 1 | +[[deps-without-boot]] |
| 2 | += Getting Dependencies without Spring Boot |
| 3 | + |
| 4 | +We recommend a Spring Boot first approach when using Spring for Apache Pulsar. |
| 5 | +However, if you do not use Spring Boot, the preferred way to get the dependencies is to use the provided BOM to ensure a consistent version of modules is used throughout your entire project. |
| 6 | +The following example shows how to do so for both Maven and Gradle: |
| 7 | + |
| 8 | +[tabs] |
| 9 | +====== |
| 10 | +Maven:: |
| 11 | ++ |
| 12 | +.pom.xml |
| 13 | +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] |
| 14 | +---- |
| 15 | +<dependencyManagement> |
| 16 | + <dependencies> |
| 17 | + <!-- ... other dependency elements ... --> |
| 18 | + <dependency> |
| 19 | + <groupId>org.springframework.pulsar</groupId> |
| 20 | + <artifactId>spring-pulsar-bom</artifactId> |
| 21 | + <version>{spring-pulsar-version}</version> |
| 22 | + <type>pom</type> |
| 23 | + <scope>import</scope> |
| 24 | + </dependency> |
| 25 | + </dependencies> |
| 26 | +</dependencyManagement> |
| 27 | +---- |
| 28 | +
|
| 29 | +Gradle:: |
| 30 | ++ |
| 31 | +.build.gradle |
| 32 | +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] |
| 33 | +---- |
| 34 | +plugins { |
| 35 | + id "io.spring.dependency-management" version "1.1.4" |
| 36 | +} |
| 37 | +
|
| 38 | +dependencyManagement { |
| 39 | + imports { |
| 40 | + mavenBom 'org.springframework.pulsar:spring-pulsar-bom:{spring-pulsar-version}' |
| 41 | + } |
| 42 | +} |
| 43 | +---- |
| 44 | +====== |
| 45 | + |
| 46 | +A minimal Spring for Apache Pulsar set of dependencies typically looks like the following: |
| 47 | + |
| 48 | +[tabs] |
| 49 | +====== |
| 50 | +Maven:: |
| 51 | ++ |
| 52 | +.pom.xml |
| 53 | +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] |
| 54 | +---- |
| 55 | +<dependencies> |
| 56 | + <!-- ... other dependency elements ... --> |
| 57 | + <dependency> |
| 58 | + <groupId>org.springframework.pulsar</groupId> |
| 59 | + <artifactId>spring-pulsar</artifactId> |
| 60 | + </dependency> |
| 61 | +</dependencies> |
| 62 | +---- |
| 63 | +
|
| 64 | +Gradle:: |
| 65 | ++ |
| 66 | +.build.gradle |
| 67 | +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] |
| 68 | +---- |
| 69 | +dependencies { |
| 70 | + implementation "org.springframework.pulsar:spring-pulsar" |
| 71 | +} |
| 72 | +---- |
| 73 | +====== |
| 74 | + |
| 75 | +If you use additional features (such as Reactive), you need to also include the appropriate dependencies. |
| 76 | + |
| 77 | +Spring for Apache Pulsar builds against Spring Framework {spring-framework-version} but should generally work with any newer version of Spring Framework 6.x. |
| 78 | +Many users are likely to run afoul of the fact that Spring for Apache Pulsar's transitive dependencies resolve Spring Framework {spring-framework-version}, which can cause strange classpath problems. |
| 79 | +The easiest way to resolve this is to use the `spring-framework-bom` within your `dependencyManagement` section as follows: |
| 80 | + |
| 81 | +[tabs] |
| 82 | +====== |
| 83 | +Maven:: |
| 84 | ++ |
| 85 | +.pom.xml |
| 86 | +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] |
| 87 | +---- |
| 88 | +<dependencyManagement> |
| 89 | + <dependencies> |
| 90 | + <!-- ... other dependency elements ... --> |
| 91 | + <dependency> |
| 92 | + <groupId>org.springframework</groupId> |
| 93 | + <artifactId>spring-framework-bom</artifactId> |
| 94 | + <version>{spring-framework-version}</version> |
| 95 | + <type>pom</type> |
| 96 | + <scope>import</scope> |
| 97 | + </dependency> |
| 98 | + </dependencies> |
| 99 | +</dependencyManagement> |
| 100 | +---- |
| 101 | +
|
| 102 | +Gradle:: |
| 103 | ++ |
| 104 | +.build.gradle |
| 105 | +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] |
| 106 | +---- |
| 107 | +plugins { |
| 108 | + id "io.spring.dependency-management" version "1.1.4" |
| 109 | +} |
| 110 | +
|
| 111 | +dependencyManagement { |
| 112 | + imports { |
| 113 | + mavenBom 'org.springframework:spring-framework-bom:{spring-framework-version}' |
| 114 | + } |
| 115 | +} |
| 116 | +---- |
| 117 | +====== |
| 118 | + |
| 119 | +The preceding example ensures that all the transitive dependencies of Spring for Apache Pulsar use the Spring {spring-framework-version} modules. |
0 commit comments