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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 【原创】大叔经验分享(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 ...

  5. 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 ...

  6. nested exception is java.lang.IllegalStateException: Context namespace element 'annotation-config' a

    公司还用的是spring低版本,今天用jre 8测试了一下,发现错误: Unexpected exception parsing XML document from class path resour ...

  7. 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 ...

  8. 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 ...

  9. spring java config 初探

    Java Config 注解 spring java config作为同xml配置形式的另一种表达形式,使用的场景越来越多,在新版本的spring boot中 大量使用,今天我们来看下用到的主要注解有 ...

随机推荐

  1. Iosapp升级版本步骤

    1.打开地址https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa,登录进入 2.选择ManageYour App,选中你要升级的那个 ...

  2. 【spring cloud】子模块启动报错com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect

    spring cloud子模块启动报错 Caused by: java.lang.ClassNotFoundException: com.netflix.hystrix.contrib.javanic ...

  3. Can''t find the channel handler for deviceType 工行 个人网银 错误

    背景描述:系统Win7,浏览器IE8.登录工商银行个人网银的时候,输入帐号密码和验证码后,出现空白页面,上面一句话  Can''t find the channel handler for devic ...

  4. Youtube深度学习推荐系统论文

    https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/45530.pdf https://zh ...

  5. 2016.7.12 去除mybatis-generator生成的class里的注释

    用mybatis-generator自动生成代码会出现很多没必要的注释.     在配置文件里加上: 是否去除所有自动生成的文件的时间戳: 是否去除所有自动生成文件的注释: <commentGe ...

  6. 「工具」Dubbo可视化测试工具的设计和实现

    「工具」Dubbo可视化测试工具的设计和实现 学习了:https://blog.csdn.net/qq355667166/article/details/78914453

  7. base64编码-----------》struts2(token)利用BigInteger产生随机数

    //struts2 源码 public static final Random RANDOM= new Random(); public static String generateGUID(){ r ...

  8. jquery:给正则表达式添加变量

    http://www.2cto.com/kf/201402/277766.html 正则表达式普通用法:var checkString=/^.*\S+.*$/;  //注意正则表达式没有引号 chec ...

  9. SW线路中串联1K电阻的作用

    主要作用的去ESD,去干扰 和ADC上串的一样一样的作用 物美价廉的ESD方案 我还是觉得起到控制开关打开的快慢,也就是控制开关脉冲的上升沿,加了这个1K电阻,可以减缓上升延的斜率.如果上升沿过快,会 ...

  10. Android应用开发:网络工具——Volley(一)

    引言 网络一直是我个人的盲点,前一阵子抽空学习了一下Volley网络工具的用法,也透过源代码进行了进一步的学习,有一些心得想分享出来.在Android开发中,成熟的网络工具不少,Android自带了H ...