java.lang.AbstractMethodError:
org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator.determineConstructor(
Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/reflect/Constructor;
`AbstractMethodError` 表示:運行時類別中缺少編譯時存在的方法**。
`BeanNameAutoProxyCreator.determineConstructor` 方法簽名在 Spring 版本間發生變更,導致 **AOP 模組 (spring-aop) 與核心模組 (spring-beans/spring-context) 版本不一致**。
| 場景 | spring-aop 版本 | spring-beans/context 版本 | 結果 |
|---|---|---|---|
| 舊專案升級 | 5.3.x | 4.3.x / 5.0.x | ❌ AbstractMethodError |
| 混合引入 | 4.3.x | 5.3.x | ❌ AbstractMethodError |
| 第三方庫傳遞依賴 | 不同版本 | 不同版本 | ❌ 衝突 |
5.3.30
org.springframework
spring-framework-bom
${spring.version}
pom
import
org.springframework
spring-aop
org.springframework
spring-context
org.springframework
spring-jdbc
dependencies {
// 使用 Spring BOM
implementation platform('org.springframework:spring-framework-bom:5.3.30')
implementation 'org.springframework:spring-aop'
implementation 'org.springframework:spring-context'
implementation 'org.springframework:spring-jdbc'
// ...
}
mvn dependency:tree | grep spring
# 或
gradle dependencies --configuration compileClasspath | grep spring
確認**所有** `org.springframework:*` 版本完全一致
com.thirdparty
some-lib
org.springframework
*
原回答建議檢查資料源用戶名密碼、換連接池,**這是錯誤誤導**。`AbstractMethodError` 純屬 **類別檔案版本不匹配**,與資料庫連線零關係。
*Service
*Dao
transactionAdvisor
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED,readOnly
**強烈建議棄用 `BeanNameAutoProxyCreator` (Spring 1.x/2.x 遺物)**,改用註解驅動:
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true) // CGLIB 代理
@EnableTransactionManagement
public class AppConfig {
@Bean
public PlatformTransactionManager txManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}
// Service 類
@Service
public class UserService {
@Transactional
public void save(User u) { ... }
}
`AbstractMethodError: determineConstructor` **100% 是 Spring 模組版本不一致**。解決核心:**引入 `spring-framework-bom` 統一版本、清理傳遞依賴衝突、避免應用伺服器共享庫干擾**。資料源配置與此錯誤無關。現代專案請改用 `@EnableAspectJAutoProxy` + `@Transactional` 註解式 AOP/事務管理。