Skip to content

Commit b12e751

Browse files
committed
fix: align logging dependencies with Spring Boot by excluding incompatible SLF4J and Logback versions
1 parent 0a39bed commit b12e751

File tree

1 file changed

+56
-5
lines changed

1 file changed

+56
-5
lines changed

Diff for: vertical-slice-architecture/pom.xml

+56-5
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,78 @@
3535
<version>1.26.0-SNAPSHOT</version>
3636
</parent>
3737
<dependencies>
38-
<dependency>
39-
<groupId>org.springframework.boot</groupId>
40-
<artifactId>spring-boot-starter-web</artifactId>
38+
<!--
39+
Exclude problematic versions from the parent:
40+
41+
The parent POM includes newer versions of SLF4J (2.x) and Logback (1.5.x)
42+
that are not compatible with the Spring Boot 2.7.x logging setup, which
43+
relies on SLF4J 1.7.x and Logback 1.2.x. If these newer versions remain,
44+
they cause runtime errors due to classes like org/slf4j/impl/StaticLoggerBinder
45+
no longer existing where Spring Boot expects them.
46+
47+
By excluding these dependencies, we ensure that our module only uses versions
48+
of SLF4J and Logback that align with the Spring Boot ecosystem. This approach
49+
helps prevent `NoClassDefFoundError` issues and ensures stable, expected
50+
logging behavior within this module.
51+
--> <dependency>
52+
<groupId>com.iluwatar</groupId>
53+
<artifactId>java-design-patterns</artifactId>
54+
<version>1.26.0-SNAPSHOT</version>
55+
<exclusions>
56+
<exclusion>
57+
<groupId>org.slf4j</groupId>
58+
<artifactId>slf4j-api</artifactId>
59+
</exclusion>
60+
<exclusion>
61+
<groupId>ch.qos.logback</groupId>
62+
<artifactId>logback-classic</artifactId>
63+
</exclusion>
64+
<exclusion>
65+
<groupId>ch.qos.logback</groupId>
66+
<artifactId>logback-core</artifactId>
67+
</exclusion>
68+
</exclusions>
4169
</dependency>
70+
71+
<!-- Add Spring Boot starters -->
4272
<dependency>
4373
<groupId>org.springframework.boot</groupId>
44-
<artifactId>spring-boot-starter-test</artifactId>
45-
<scope>test</scope>
74+
<artifactId>spring-boot-starter-web</artifactId>
4675
</dependency>
76+
4777
<dependency>
4878
<groupId>org.springframework.boot</groupId>
4979
<artifactId>spring-boot-starter-data-jpa</artifactId>
5080
</dependency>
81+
5182
<dependency>
5283
<groupId>com.h2database</groupId>
5384
<artifactId>h2</artifactId>
5485
<scope>runtime</scope>
5586
</dependency>
5687

88+
<!-- Force recommended SLF4J and Logback versions if you must specify them explicitly -->
89+
<dependency>
90+
<groupId>org.slf4j</groupId>
91+
<artifactId>slf4j-api</artifactId>
92+
<version>1.7.36</version> <!-- A version compatible with Spring Boot 2.7.x -->
93+
</dependency>
94+
95+
<dependency>
96+
<groupId>ch.qos.logback</groupId>
97+
<artifactId>logback-classic</artifactId>
98+
<version>1.2.11</version> <!-- A version compatible with Spring Boot 2.7.x -->
99+
</dependency>
100+
101+
<dependency>
102+
<groupId>ch.qos.logback</groupId>
103+
<artifactId>logback-core</artifactId>
104+
<version>1.2.11</version>
105+
</dependency>
106+
57107
</dependencies>
58108

109+
59110
<build>
60111
<plugins>
61112
<plugin>

0 commit comments

Comments
 (0)