Spring 4.0 与 Java JDK 版本 7 的兼容性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23321117/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring 4.0 compatibility with Java JDK version 7
提问by Sid
Our team is planning on moving to Java 7 from Java 6 and to Spring 4.0 from Spring 3.x.
我们的团队计划从 Java 6 迁移到 Java 7,从 Spring 3.x 迁移到 Spring 4.0。
My question is how much is Spring 4.0 tuned for Java 7. I have found online that Spring 4.0 is Java 8 ready, but nothing specific for Java 7.
我的问题是 Spring 4.0 为 Java 7 做了多少调整。我在网上发现 Spring 4.0 已经为 Java 8 做好了准备,但没有专门针对 Java 7。
采纳答案by Krishna
Spring 4 provides very good support for Java 8 version. It means that they have good support for Java 7 too. If you are planning to use Spring 4 with Java 7 or 8, there should not be any issues. It will be perfectly matching. However, Spring 4 has upgraded their framework API compatible with Java 8 code which has lot of improvements in the language like Lambdas, etc.
Spring 4 对 Java 8 版本提供了很好的支持。这意味着它们对 Java 7 也有很好的支持。如果您计划将 Spring 4 与 Java 7 或 8 一起使用,应该不会有任何问题。它将完美匹配。但是,Spring 4 已经升级了与 Java 8 代码兼容的框架 API,在语言方面有很多改进,如 Lambdas 等。
It is always backwards compatible and you need not worry anything since more than. 90% of the project will be using Java 6 or 7 for the next couple of years.
它始终向后兼容,因此您无需担心任何事情。在接下来的几年里,90% 的项目将使用 Java 6 或 7。
My advice is that, if you could start your project with Java 8, that is good for the future since migrating later will have more changes with syntax of the new Apis. Also this is the information provided by Spring team about the Java 8 support on Spring:
我的建议是,如果您可以使用 Java 8 开始您的项目,那对未来有好处,因为稍后迁移会对新 API 的语法进行更多更改。这也是 Spring 团队提供的有关 Spring 上 Java 8 支持的信息:
Java 8 is a perfect fit for Spring's programming model. We believe that the combination is very attractive, with Java 8 offering elegant language features and library improvements for immediate use with typical Spring APIs. In fact, Spring Framework 4.0 is the first fully Java 8 enabled application framework in the industry. We went the extra mile to provide everything that is necessary to start developing Spring applications on Java 8 today, even before the production launch of Java 8 in March.
Java 8 非常适合 Spring 的编程模型。我们相信这种组合非常有吸引力,Java 8 提供了优雅的语言特性和库改进,可立即与典型的 Spring API 一起使用。事实上,Spring Framework 4.0 是业界第一个完全支持 Java 8 的应用程序框架。我们付出了额外的努力,以提供今天开始在 Java 8 上开发 Spring 应用程序所需的一切,甚至在 3 月份 Java 8 的生产发布之前。
also I have found useful details in the spring documentation http://docs.spring.io/spring/docs/current/spring-framework-reference/html/new-in-4.0.html.
我还在 spring 文档http://docs.spring.io/spring/docs/current/spring-framework-reference/html/new-in-4.0.html 中找到了有用的细节。
They have clearly mentioned as
他们已经明确提到
However, for newly started development projects based on Spring 4, we recommend the use of Java 7 or 8.
但是,对于新开始的基于 Spring 4 的开发项目,我们建议使用 Java 7 或 8。
Note that minimum supported Java version for Spring 4 is raised to Java 6.
请注意,Spring 4 支持的最低 Java 版本已提升到 Java 6。
Hope this answer helps you.
希望这个回答对你有帮助。
回答by ticktock
I've stumbled on a few problems... namely if you're compiling with -Werror on and use something like the PropertySource annotation, that imports a Java 8 class Repeatable and fails to allow your project to successfully compile. If you avoid these classes you're ok, but then.. you're not using the latest spring 4 functionality then.
我偶然发现了一些问题……也就是说,如果您使用 -Werror 进行编译并使用类似 PropertySource 注释的内容,则会导入 Java 8 类可重复,并且无法让您的项目成功编译。如果您避免使用这些类,那么您就可以了,但是……您没有使用最新的 spring 4 功能。