Migrating to Spring 4 from Spring 3 - What you need to know
Transcript of Migrating to Spring 4 from Spring 3 - What you need to know
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Migrating from Spring 3 to Spring 4By Phillip Verheyden
@phillipuniverse
Do you use Spring? Is eCommerce your business?
Want to ride with us on the future-train of Java eCommerce? !
Then use Broadleaf! https://github.com/BroadleafCommerce http://demo.broadleafcommerce.com http://www.broadleafcommerce.com
4
This Talk
• Upgrades in general • Spring 4 specifically
• Dependencies • Taking advantage of new (-ish) features
• Java configuration • Web Sockets
5
Why should you invest in a upgrade/migration?
• Talent acquisition/retention • “Nobody ever got fired for choosing…”
• Stagnation/debt • Code you no longer have to support • Supported versions
• Who is still on Java 6? (IBM?) • New features
• Programming == fun (?) • Feature enablement++ (see Web Sockets, Lambdas)
7
How we did it
• First pass - initial update for compilation • Pass++
• Java-based configuration, resource handling
11
What does the upgrade path look like?
• Migration guide on GitHub • Skip 4.0.6.RELEASE, go directly to 4.1.0.RELEASE • TL;DR - it’s not that bad
13
Spring 4 recommended minimum versions
• In general, versions released in 2010 and later • Full list • Spring IO Platform • JPA 2.0 • Jackson 2 - no Jackson 1 support in Spring 4.1 • Hibernate 3.6 - Hibernate 4 recommended • Servlet 3.0 - Servlet 2.5 still deployable with excluded features
• Required for Spring MVC tests • Spring Security 3.2 • Thymeleaf - specific Spring 4 package
15
Spring 4 recommended minimum versions
• Servers • Tomcat 6.0.33 / 7.0.20 • Jetty 7.5 • JBOSS AS 6.1 • GlassFish 3.1 (with a workaround) • Oracle WebLogic 10.3.4 (with JPA 2.0) • IBM WebSphere 7.0.0.9 (with JPA 2.0)
16
Jackson
• Jackson 1.x to 2.x • Maintainer change from Codehaus to FasterXML
• Java package change from org.codehaus.jackson to com.fasterxml.jackson.core
• Want to use JAXRS? • Add jackson-jaxrs-json-provider
• Want to use JAXB annotations with Jackson serialization? Add jackson-module-jaxb-annotations
17
Transitively includes jackson-annotations
and jackson-core
XSD Updates
• If you are utilizing the Spring XML namespaces, you should update these to target the -4.1.xsd • Or use the version-less version
19
What can you immediately use in Spring 4?
• Lots of topics already covered (Java 8, sockets, resource handling)
• Java config (now is a great time to start using it) • Spring Security 3.2
• Auto CSRF protection • Better Java config
• @RestController• Ordered list bean injection • Generic injection (e.g. @Autowired Repository<Order>) • Spring MVC test framework
21
$('');
What did we learn
• Upgrading == good • You don’t need to do a huge re-platform (good backwards
compatibility) • Tiered feature upgrade might be the best option • Java config - now with more standard Java extension patterns • Simple real-world web socket support is sick!
25