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中 大量使用,今天我们来看下用到的主要注解有 ...
随机推荐
- 成长笔记--解决Eclipse 变量名的自动补全问题
大家使用eclipse敲代码的时候,是不是都被这样一个问题困扰着.就是键入一个变量名的时候,会自动提示补全:在你的变量名后面加上类型的名字!这个时候,你就必须键入Esc才不会自动补全你的变量,如果你键 ...
- WPF 自动验证
WPF中TextBox的自动验证: 演示 : 用以下两个TextBox分别显示验证IP和非空值验证,先看效果: IP自动验证效果: 非空值自动验证效果: 第一步:定义TextBox验证的样式: < ...
- VisualStudio 2013 Prieview体验
今天看到VisualStudio 2013的预览版发布了,便立即下载试用了一下. 主体界面和VS2012非常类似,不过色彩要稍微丰富点. 现在支持用MS账户登录了,登陆后可以同步设置,这个小功能还是比 ...
- Linux基础学习4
SUDO sudo 执行的重点是:『 能否使用 sudo 必须要看 /etc/sudoers 的设定值, 而可使用 sudo者是透过输入用户自己的密码来执行后续的指令串』由于能否使用与/etc/sud ...
- IOS7开发~UIKit Dynamics
UIKit Dynamics的中文名称:有叫UIKit动力,也有叫UIKit动力模型和UIKit动态或者动态UI,叫什么名不要紧,理解就含义就可以了. 什么是UIKit Dynamics ? UIKi ...
- zabbix监控系统-部署规划
- linux下crontab使用笔记
1. 安装 service crond status yum install vixie-cron yum install crontabs 2. 实例 每分钟 ...
- 国家商用password(五)基于SM2的软件授权码生成及校验
将公开密钥算法作为软件注冊算法的优点是Cracker非常难通过跟踪验证算法得到注冊机.以下.将介绍使用SM2国密算法进行软件注冊的方法. 生成授权码 选择SM2椭圆曲线參数(P,a,b,N,Gx,Gy ...
- iOS开发--从TQRichTextViewDemo中学会分析project
下载地址: http://code4app.com/ios/TQRichTextView/5244fe9c6803fa0862000000 1.首先找到AppDelegate类.不管一个project ...
- fastjson设置生成的json属性的顺序
目标JSON顺序: {,,} 1.url2.w3.h4.s 如果使用默认情况生成,则顺序为: w,h,s,url 在fastJson中,可以使用@JSONField来指定属性顺序(需要1.1.42以上 ...