Files
CasService/pom.xml
T
chenxing 7ff337373c
build / build-push (push) Successful in 1m46s
修复 log4j2 双版本混包导致的启动失败
现象:java -jar cas.war 启动即抛 NoSuchMethodError: ThreadContext.getThreadContextMap,
WAR 的 WEB-INF/lib 同时存在 log4j api/core/slf4j-impl 的 2.7 与 2.12.1 两套。

根因:spring-boot-dependencies 1.5.18 经内嵌 log4j-bom 管理 log4j 版本,默认 2.7;
BOM import 方式下 pom 覆盖 <log4j2.version> 属性不生效(属性在导入 BOM 自身上下文解析),
maven 仍解析出 2.7 全套,与 overlay war 物理自带的 2.12.1 混包,类加载顺序决定成败。

修复:dependencyManagement 最前(先声明者优先)import log4j-bom 2.12.1,
全套 log4j 钉死 2.12.1,与 overlay war 内物理版本一致,war 内仅剩单套。
2026-08-31 20:01:14 +08:00

365 lines
16 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd ">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-overlay</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<properties>
<cas.version>5.3.16</cas.version>
<springboot.version>1.5.18.RELEASE</springboot.version>
<app.server>-tomcat</app.server>
<mainClassName>org.springframework.boot.loader.WarLauncher</mainClassName>
<isExecutable>false</isExecutable>
<manifestFileToUse>${project.build.directory}/war/work/org.apereo.cas/cas-server-webapp${app.server}/META-INF/MANIFEST.MF</manifestFileToUse>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- 覆盖 spring-boot-dependencies 默认的 thymeleaf 2.1.6,与 CAS 5.3.16 自带的 3.0.11 对齐,避免双版本冲突 -->
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
<thymeleaf-spring4.version>3.0.11.RELEASE</thymeleaf-spring4.version>
<!-- 覆盖 spring-boot-dependencies 默认版本,与 CAS 5.3.16 webapp 自带版本对齐,消除双版本冲突 -->
<spring.version>4.3.25.RELEASE</spring.version>
<jackson.version>2.9.9</jackson.version>
<tomcat.version>8.5.47</tomcat.version>
<log4j2.version>2.12.1</log4j2.version>
<hikari.version>3.2.0</hikari.version>
<spring-security.version>4.2.10.RELEASE</spring-security.version>
<caffeine.version>2.6.2</caffeine.version>
<commons-codec.version>1.11</commons-codec.version>
<metrics.version>3.2.5</metrics.version>
</properties>
<!-- ===== 新增 Dependency Management ===== -->
<dependencyManagement>
<dependencies>
<!-- log4j 全套钉死 2.12.1(与 overlay war 内物理自带版本一致)。
关键:spring-boot-dependencies 1.5.18 经 log4j-bom 管 log4j 版本,其属性 log4j2.version 默认 2.7,
且 BOM import 方式下在 pom properties 里覆盖 <log4j2.version> 不生效(属性在导入 BOM 自身上下文解析)。
此处把 log4j-bom 2.12.1 放在 spring-boot-dependencies 之前 import(先声明者优先),
否则 maven 会解析出 2.7 全套、与 overlay war 自带的 2.12.1 物理文件混包,
运行期 api/core 版本错配 → NoSuchMethodError: ThreadContext.getThreadContextMap -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>2.12.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${springboot.version}</version>
<type>pom</type>
<scope>import</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>com.rimerosolutions.maven.plugins</groupId>
<artifactId>wrapper-maven-plugin</artifactId>
<version>0.0.5</version>
<configuration>
<verifyDownload>true</verifyDownload>
<checksumAlgorithm>MD5</checksumAlgorithm>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<configuration>
<mainClass>${mainClassName}</mainClass>
<addResources>true</addResources>
<executable>${isExecutable}</executable>
<layout>WAR</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warName>cas</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
<recompressZippedFiles>false</recompressZippedFiles>
<archive>
<compress>false</compress>
<manifestFile>${manifestFileToUse}</manifestFile>
</archive>
<overlays>
<overlay>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-webapp${app.server}</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
</plugin>
</plugins>
<finalName>cas</finalName>
</build>
<!-- 不声明外网仓库(sonatype/shibboleth 已移除):CAS 5.3.16 全部依赖都在 Maven Central,
CI(内网 runner 无外网)与本地(maven-settings.xml 指公司 nexus maven-public)均经 nexus 代理解析 -->
<profiles>
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<id>default</id>
<dependencies>
<!-- CAS Web 应用 -->
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-webapp${app.server}</artifactId>
<version>${cas.version}</version>
<type>war</type>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- CAS 核心 API -->
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-api-authentication</artifactId>
<version>${cas.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-authentication-api</artifactId>
<version>${cas.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-configuration-api</artifactId>
<version>${cas.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-api-ticket</artifactId>
<version>${cas.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-configuration</artifactId>
<version>${cas.version}</version>
<scope>provided</scope>
</dependency>
<!-- SSO 会话所需:CentralAuthenticationService 等核心 API -->
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-api</artifactId>
<version>${cas.version}</version>
<scope>provided</scope>
</dependency>
<!-- SSO 会话所需:CookieRetrievingCookieGenerator / TGCCookieRetrievingCookieGenerator -->
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-cookie-api</artifactId>
<version>${cas.version}</version>
<scope>provided</scope>
</dependency>
<!-- SSO 会话所需:WebApplicationServiceFactory(构造 Service 以签发 ST) -->
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-services-authentication</artifactId>
<version>${cas.version}</version>
<scope>provided</scope>
</dependency>
<!-- Spring Boot Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Log4j2 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>${springboot.version}</version>
</dependency>
<!-- Redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 验证码 -->
<dependency>
<groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
<version>2.3.2</version>
</dependency>
<!-- RSA -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.68</version>
</dependency>
<!-- Fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<!-- ===== JDBC + MySQL ===== -->
<!-- JDBC 支持(排除 HikariCP) -->
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-jdbc</artifactId>
<version>${cas.version}</version>
<exclusions>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-jdbc-drivers</artifactId>
<version>${cas.version}</version>
<exclusions>
<exclusion>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 正确版本的 HikariCP(与 webapp 自带 3.2.0 对齐) -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.2.0</version>
<scope>provided</scope>
</dependency>
<!-- MySQL 驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
</dependency>
<!-- Spring Security Config(提供 WebSecurityConfigurerAdapter、HttpSecurity 等;webapp 不自带,必须打包进 WAR) -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<!-- Spring Security Web(提供 WebSecurity 等;webapp 不自带,必须打包进 WAR) -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<!-- Spring Security Crypto(BCrypt) -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>4.2.10.RELEASE</version>
<scope>provided</scope>
</dependency>
<!-- SnakeYAML:解析 Nacos 下发的 YAML 配置(webapp 已自带 1.17,provided 仅用于编译期,运行期复用 webapp 版本避免冲突) -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.17</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>