简体   繁体   English

Java使用Spring从5升级到8

[英]Java Upgrade from 5 to 8 with Spring

I am working on a legacy application which is still running on JDK5. 我正在研究仍在JDK5上运行的遗留应用程序。 As part of our new requirement we need to update it to JDK 8. As per my understanding since Java is backward compatible, this should have worked. 作为我们新要求的一部分,我们需要将其更新为JDK 8.根据我的理解,因为Java是向后兼容的,所以这应该有效。 When I compiled with JDK 8 , the build was successful. 当我使用JDK 8编译时,构建成功。 But while launching ,I got the following error : 但是在启动时,我收到以下错误:

Error creating bean with name 'AuthorisationDialogController' defined in class path resource [com/some/application/conf/dispense/dispense-controllers.xml]: Error setting property values; 在类路径资源[com / some / application / conf / dispense / dispense-controllers.xml]中定义名为'AuthorisationDialogController'的bean时出错:设置属性值时出错; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); 嵌套异常是org.springframework.beans.PropertyAccessExceptionsException:PropertyAccessExceptionsException(1个错误); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.some.application.dispense.context.DispenseContextImpl] to required type [com.some.application.admin.AdminContext] for property 'context'] 嵌套的propertyAccessExceptions是:[org.springframework.beans.TypeMismatchException:无法将[com.some.application.dispense.context.DispenseContextImpl]类型的属性值转换为属性所需的类型[com.some.application.admin.AdminContext]上下文']

My dependencies looks like the following: 我的依赖项如下所示:

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>1.2.7</version>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>2.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymockclassextension</artifactId>
            <version>2.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.1_3</version>
        </dependency>
        <dependency>
            <groupId>com.micros</groupId>
            <artifactId>aaaa</artifactId>
            <version>${externalVendor}</version>
        </dependency>
        <dependency>
            <groupId>com.micros</groupId>
            <artifactId>bbb</artifactId>
            <version>${externalVendor}</version>
        </dependency>
        <dependency>
            <groupId>com.micros</groupId>
            <artifactId>ccc</artifactId>
            <version>${externalVendor}</version>
        </dependency>
        <dependency>
            <groupId>com.micros</groupId>
            <artifactId>ddd</artifactId>
            <version>${externalVendor}</version>
        </dependency>
        <dependency>
            <groupId>com.micros</groupId>
            <artifactId>eeee</artifactId>
            <version>${externalVendor}</version>
        </dependency>
    </dependencies>

I googled and found out that Spring1.2.6 might not support JDK8. 我用Google搜索并发现Spring1.2.6可能不支持JDK8。 Please can anyone help me what all things I need to take care here. 请允许任何人帮助我在这里需要注意的所有事情。 We also have dependency on some external vendor which is built on top of Java5. 我们还依赖于一些基于Java5构建的外部供应商。

If Spring was a library, you would have seen success. 如果Spring是一个图书馆,你会看到成功。 It is not, it is a framework. 它不是,它是一个框架。

This means that the Spring framework needs to understand the plugins that provide the logic that solves the rest of the "problem" your program addresses. 这意味着Spring框架需要了解提供解决程序所解决的“问题”其余部分的逻辑的插件。 To do the correct injections and wiring, Spring uses libraries that inspect and configure the plugins written to be managed by Spring. 为了进行正确的注入和连线,Spring使用库来检查和配置由Spring管理的插件。

These libraries do reflection and byte code processing on the plugins. 这些库对插件进行反射和字节代码处理。 This means that the Spring framework needs to understand Java 8 bytecode. 这意味着Spring框架需要理解Java 8字节码。 Your version of Spring doesn't. 你的Spring版本没有。 To get a Spring that does, you would update the Apache Maven dependency for Spring; 要获得一个Spring,你可以更新Spring的Apache Maven依赖项; but that will trigger the need to update the plugins to correctly operate with the new Spring version. 但这将触发更新插件的需要,以便正确使用新的Spring版本。

In short, you're going to have to migrate a lot more dependencies to newer versions to support Java 8. 简而言之,您将不得不将更多依赖项迁移到更新版本以支持Java 8。

Frameworks can be great things, as they can save a lot of time; 框架可以是很棒的东西,因为它们可以节省大量时间; but, there is an software architecture risk. 但是,存在软件架构风险。 If the framework needs updating, all of the plugin components may need modification to migrate to the new version. 如果框架需要更新,则可能需要修改所有插件组件才能迁移到新版本。 Spring is no exception. 春天也不例外。

This is why some people prefer to leverage libraries; 这就是为什么有些人更喜欢利用图书馆; but, libraries are not a panacea, because you often need to decide how to integrate them (which means you're writing your own framework, but that's easier to control the migrate forward than someone else's framework). 但是,库并不是灵丹妙药,因为您经常需要决定如何集成它们(这意味着您正在编写自己的框架,但这比其他人的框架更容易控制迁移)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JAVA Spring Rest API环境升级计划 - JAVA Spring Rest API environment upgrade plan 如何在spring应用程序中将JDK版本从java版本“1.8.0_152”升级到jdk-8u211 - how to upgrade JDK version from java version "1.8.0_152" to jdk-8u211 in the spring application 运行时 java.lang.NoClassDefFoundError: Lorg/springframework/beans/factory/access/BeanFactoryReference 后 Spring 从 4 升级到 5 - Runtime java.lang.NoClassDefFoundError: Lorg/springframework/beans/factory/access/BeanFactoryReference after Spring upgrade from 4 to 5 将Spring Webflow从1.0.6升级到2.3 - Upgrade Spring Webflow from 1.0.6 to 2.3 Spring 引导 Freemarker 从 2.2.0 升级失败 - Spring Boot Freemarker fails from 2.2.0 upgrade 从 Spring security 3 升级到 Spring security 4 后出现异常? - Getting exceptions after upgrade from Spring security 3 to Spring security 4? Spring Boot 2升级java.lang.ClassNotFoundException:EmbeddedServletContainerCustomizer - Spring Boot 2 upgrade java.lang.ClassNotFoundException: EmbeddedServletContainerCustomizer 如何将代码从Java 1.3升级到1.5 - How to upgrade a code from java 1.3 to 1.5 将 Java 应用程序从旧版本升级到最新版本 - Upgrade java applications from old to a newest version Swing应用程序从Java 1.7升级到1.8 - Swing application upgrade from Java 1.7 to 1.8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM