Spring/Java error: namespace element 'annotation-config' … on JDK 1.5 and higher
Extract the jar file:
mkdir spring
cd spring
jar xvf ../spring.jar
Check the Spring version in META-INF/MANIFEST.MF (you should see something like version=2.5.5). Look up the appropriate version of JdkVersion.java and use that as a starting point (the example below is for Spring 2.5.5 and you don't want to change any method signatures from the version you're working with).
Check the major and minor version of the JdkVersion.class file:
javap -verbose org/springframework/core/JdkVersion.class
We see that the class was original compiled as target 48.0 (looking this up, we find that is Java 1.4):
Classfile /tmp/spring/org/springframework/core/JdkVersion.class
Last modified Jun 23, 2008; size 1286 bytes
MD5 checksum 98e6ea08ce9186c50cc71d14465fc3dd
Compiled from "JdkVersion.java"
public abstract class org.springframework.core.JdkVersion
minor version: 0
major version: 48
flags: ACC_PUBLIC, ACC_SUPER, ACC_ABSTRACT
Constant pool:
...
Create org/springframework/core/JdkVersion.java with the following content:
package org.springframework.core;
public abstract class JdkVersion
{
public static final int JAVA_13 = 0;
public static final int JAVA_14 = 1;
public static final int JAVA_15 = 2;
public static final int JAVA_16 = 3;
public static final int JAVA_17 = 4;
private static final String javaVersion;
private static final int majorJavaVersion;
static
{
javaVersion = System.getProperty("java.version");
if (javaVersion.indexOf("1.7.") != -1)
{
majorJavaVersion = JAVA_17;
} else if (javaVersion.indexOf("1.6.") != -1) {
majorJavaVersion = JAVA_16;
} else if (javaVersion.indexOf("1.5.") != -1) {
majorJavaVersion = JAVA_15;
} else if (javaVersion.indexOf("1.4.") != -1) { // new
majorJavaVersion = JAVA_14; // new
} else {
majorJavaVersion = JAVA_17; // changed from JAVA_14
}
}
public static String getJavaVersion()
{
return javaVersion;
}
public static int getMajorJavaVersion()
{
return majorJavaVersion;
}
public static boolean isAtLeastJava14()
{
return true;
}
public static boolean isAtLeastJava15()
{
return getMajorJavaVersion() >= JAVA_15;
}
public static boolean isAtLeastJava16()
{
return getMajorJavaVersion() >= JAVA_16;
}
}
Then compile the new class as Java 1.4:
javac -source 1.4 org/springframework/core/JdkVersion.java
You can check the major.minor version again as above if needed.
Create the modified jar file (without overwriting the original manifest):
jar Mcf ../spring-modified.jar *
Copy the modified jar file where needed (as spring.jar or as appropriate).
https://stackoverflow.com/questions/23813369/spring-java-error-namespace-element-annotation-config-on-jdk-1-5-and-high/29647933#29647933
Spring/Java error: namespace element 'annotation-config' … on JDK 1.5 and higher的更多相关文章
- spring 2.5.6 错误:Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
在运行一个第三方公司交付的项目的时候, 出现: Caused by: java.lang.IllegalStateException: Context namespace element 'annot ...
- spring低版本报错:java.lang.IllegalStateException: Context namespace element ‘annotation-config’ and its parser class [*] are only available on
参考来源:http://blog.csdn.net/sunxiaoyu94/article/details/50492083 使用spring低版本(2.5.6),使用jre 8发现错误: Unexp ...
- Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser]
严重: Exception sending context initialized event to listener instance of class org.springframework.we ...
- 【原创】大叔经验分享(16)Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
今天尝试运行一个古老的工程,配置好之后编译通过,结果运行时报错: org.springframework.beans.factory.BeanDefinitionStoreException: Une ...
- Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
异常信息如下: 错误: Unexpected exception parsing XML document from class path resource [spring/applicationCo ...
- nested exception is java.lang.IllegalStateException: Context namespace element 'annotation-config' a
公司还用的是spring低版本,今天用jre 8测试了一下,发现错误: Unexpected exception parsing XML document from class path resour ...
- Error creating bean with name 'com.cloud.feign.interfaces.xxxFeignClient': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalSt.PathVariable annotation was empty on
环境: Spring Cloud:Finchley.M8 Spring Boot:2.0.0.RELEASE 报错信息: Error creating bean with name 'com.clou ...
- Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
Context namespace element 'annotation-config' and its parser class [org.springframework.context.anno ...
- spring java config 初探
Java Config 注解 spring java config作为同xml配置形式的另一种表达形式,使用的场景越来越多,在新版本的spring boot中 大量使用,今天我们来看下用到的主要注解有 ...
随机推荐
- Ubuntu 16.04下IntelliJ IDEA菜单显示乱码的问题解决
说明:这个问题一般是Ubuntu安装时默认使用了中文,而IDEA默认是以系统默认字体为主,所以就会出现乱码:要解决这种问题,就是在IDEA启动时强制设置为英文. 解决方式: 在idea.vmoptio ...
- (译)关于使用Eclipse Memory Analyzer的10点小技巧
作者 Rave_Tian 2016.02.01 17:56* 字数 2988 阅读 520评论 0喜欢 0 分析和理解应用的内存使用情况是开发过程中一项不小的挑战.一个微小的逻辑错误可能会导致监听器没 ...
- logback MDC(Mapped Diagnostic Context)与分布式系统的跟踪系统
logback MDC(Mapped Diagnostic Context)与分布式系统的跟踪系统 logback官方文档中第8章Mapped Diagnostic Context给我们提供了一些分布 ...
- 通过UltraISO来提取U盘启动盘的ISO镜像文件
我们先来说下UltraISO这个工具,中文名也叫软碟通,他是一个无需量产你的U盘就可以把U盘做成启动盘的工具,当然了,这么强大的工具肯定不是免费版的,对,他是共享的:但是你可以下载特别版嘛..网上到处 ...
- 3747: [POI2015]Kinoman|线段树
枚举左区间线段树维护最大值 #include<algorithm> #include<iostream> #include<cstdlib> #include< ...
- 【Java编程】JDBC注入攻击-Statement 与 PreparedStatement
在上一篇[Java编程]建立一个简单的JDBC连接-Drivers, Connection, Statement and PreparedStatement我们介绍了怎样使用JDBC驱动建立一个简单的 ...
- Linux学习之十五-Linux文件特殊权限和附加权限
Linux文件特殊权限和附加权限 1.特殊权限suid 范围:只能针对二进制命令文件 作用:让普通用户拥有二进制命令文件所有者的权限 举例1:普通用户使用passwd命令修改密码 cat /etc/s ...
- 根据DatabaseMetaData确定数据库类型
根据DatabaseMetaData确定数据库类型 DataSource dataSource = dataSourceTransactionManager.getDataSource(); conn ...
- Chrome自带恐龙小游戏的源码研究(二)
在上一篇<Chrome自带恐龙小游戏的源码研究(一)>中实现了地面的绘制和运动,这一篇主要研究云朵的绘制. 云朵的绘制通过Cloud构造函数完成.Cloud实现代码如下: Cloud.co ...
- Spark源码分析之三:Stage划分
继上篇<Spark源码分析之Job的调度模型与运行反馈>之后,我们继续来看第二阶段--Stage划分. Stage划分的大体流程如下图所示: 前面提到,对于JobSubmitted事件,我 ...