1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4 <modelVersion>4.0.0</modelVersion>
5 <parent>
6 <groupId>org.springframework.boot</groupId>
7 <artifactId>spring-boot-starter-parent</artifactId>
8 <version>3.3.3</version>
9 <relativePath/> <!-- lookup parent from repository -->
10 </parent>
11 <groupId>com.lian</groupId>
12 <artifactId>springDemo2</artifactId>
13 <version>0.0.1-SNAPSHOT</version>
14 <name>springDemo2</name>
15 <description>springDemo2</description>
16
17 <url/>
18 <licenses>
19 <license/>
20 </licenses>
21 <developers>
22 <developer/>
23 </developers>
24 <scm>
25 <connection/>
26 <developerConnection/>
27 <tag/>
28 <url/>
29 </scm>
30 <properties>
31 <java.version>17</java.version>
32 </properties>
33 <dependencies>
34
35 <!-- Hive JDBC with reload4j exclusion -->
36 <dependency>
37 <groupId>org.apache.hive</groupId>
38 <artifactId>hive-jdbc</artifactId>
39 <version>3.1.2</version>
40 <exclusions>
41 <exclusion>
42 <groupId>org.slf4j</groupId>
43 <artifactId>slf4j-reload4j</artifactId>
44 </exclusion>
45 </exclusions>
46 </dependency>
47
48 <!-- Hadoop Common -->
49 <dependency>
50 <groupId>org.apache.hadoop</groupId>
51 <artifactId>hadoop-common</artifactId>
52 <version>3.3.5</version>
53 <exclusions>
54 <exclusion>
55 <groupId>org.slf4j</groupId>
56 <artifactId>slf4j-reload4j</artifactId>
57 </exclusion>
58 </exclusions>
59 </dependency>
60
61 <!-- Spring Boot Starter Web -->
62 <dependency>
63 <groupId>org.springframework.boot</groupId>
64 <artifactId>spring-boot-starter-web</artifactId>
65 <!-- Ensure to exclude logback only if necessary -->
66 <exclusions>
67 <exclusion>
68 <groupId>org.springframework.boot</groupId>
69 <artifactId>spring-boot-starter-logging</artifactId>
70 </exclusion>
71 </exclusions>
72 </dependency>
73
74 <!-- MyBatis Spring Boot Starter -->
75 <dependency>
76 <groupId>org.mybatis.spring.boot</groupId>
77 <artifactId>mybatis-spring-boot-starter</artifactId>
78 <version>3.0.3</version>
79 <exclusions>
80 <exclusion>
81 <groupId>org.springframework.boot</groupId>
82 <artifactId>spring-boot-starter-logging</artifactId>
83 </exclusion>
84 </exclusions>
85 </dependency>
86
87 <!-- MySQL Connector -->
88 <dependency>
89 <groupId>com.mysql</groupId>
90 <artifactId>mysql-connector-j</artifactId>
91 <scope>runtime</scope>
92 </dependency>
93
94
95
96
97
98 <!-- Spring Boot Starter Test -->
99 <dependency>
100 <groupId>org.springframework.boot</groupId>
101 <artifactId>spring-boot-starter-test</artifactId>
102 <scope>test</scope>
103 </dependency>
104
105 <!-- MyBatis Spring Boot Starter Test -->
106 <dependency>
107 <groupId>org.mybatis.spring.boot</groupId>
108 <artifactId>mybatis-spring-boot-starter-test</artifactId>
109 <version>3.0.3</version>
110 <scope>test</scope>
111 </dependency>
112
113
114 <dependency>
115 <groupId>org.slf4j</groupId>
116 <artifactId>slf4j-api</artifactId>
117 <version>2.0.16</version>
118 </dependency>
119
120 <dependency>
121 <groupId>ch.qos.logback</groupId>
122 <artifactId>logback-classic</artifactId>
123 <version>1.4.11</version> <!-- Logback 1.4.x 支持 SLF4J 2.x -->
124 </dependency>
125
126
127
128 </dependencies>
129
130
131
132 <build>
133 <plugins>
134
135
136
137 </plugins>
138 </build>
139
140
141 </project>
修改之前的报错信息:大概就是两种日志发生了冲突
报错信息
SLF4J(W): Class path contains multiple SLF4J providers.
SLF4J(W): Found provider [org.slf4j.reload4j.Reload4jServiceProvider@60975100]
SLF4J(W): Found provider [ch.qos.logback.classic.spi.LogbackServiceProvider@1253e7cb]
SLF4J(W): See https://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J(I): Actual provider is of type [org.slf4j.reload4j.Reload4jServiceProvider@60975100]
Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.reload4j.Reload4jLoggerFactory loaded from file:/D:/Maven/apache-maven-3.9.5/mvn_repo/org/slf4j/slf4j-reload4j/2.0.16/slf4j-reload4j-2.0.16.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.reload4j.Reload4jLoggerFactory
at org.springframework.util.Assert.instanceCheckFailed(Assert.java:592)
at org.springframework.util.Assert.isInstanceOf(Assert.java:511)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:403)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:128)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:238)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:220)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:75)
at org.springframework.boot.SpringApplicationRunListeners.lambda$starting$0(SpringApplicationRunListeners.java:54)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
at com.lian.springdemo2.SpringDemo2Application.main(SpringDemo2Application.java:10)
修改之后
报错信息
2024-09-14T10:59:54.837+08:00 WARN 3192 --- [springDemo2] [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.lian.springdemo2]' package. Please check your configuration.
10:59:55.104 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter -
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.apache.catalina.startup.Tomcat.<init>(Tomcat.java:161)
The following method did not exist:
'void org.apache.tomcat.util.ExceptionUtils.preload()'
The calling method's class, org.apache.catalina.startup.Tomcat, was loaded from the following location:
jar:file:/D:/Maven/apache-maven-3.9.5/mvn_repo/org/apache/tomcat/embed/tomcat-embed-core/10.1.28/tomcat-embed-core-10.1.28.jar!/org/apache/catalina/startup/Tomcat.class
The called method's class, org.apache.tomcat.util.ExceptionUtils, is available from the following locations:
jar:file:/D:/Maven/apache-maven-3.9.5/mvn_repo/org/eclipse/jetty/jetty-runner/9.3.20.v20170531/jetty-runner-9.3.20.v20170531.jar!/org/apache/tomcat/util/ExceptionUtils.class
jar:file:/D:/Maven/apache-maven-3.9.5/mvn_repo/org/apache/tomcat/embed/tomcat-embed-core/10.1.28/tomcat-embed-core-10.1.28.jar!/org/apache/tomcat/util/ExceptionUtils.class
The called method's class hierarchy was loaded from the following locations:
org.apache.tomcat.util.ExceptionUtils: file:/D:/Maven/apache-maven-3.9.5/mvn_repo/org/eclipse/jetty/jetty-runner/9.3.20.v20170531/jetty-runner-9.3.20.v20170531.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes org.apache.catalina.startup.Tomcat and org.apache.tomcat.util.ExceptionUtils
Process finished with exit code 1