I am trying to integrate hazel cast and hibernate in a spring application. I intend to use hazelcast as 2nd level cache for hibernate.
I am using hazelcast 2.4 and hibernate 4.1. The spring version is 3.1. How do I correctly find the dependencies and their correct version. I have spent some time to get that right and and I will figure that out in some time. But what is the best way to figure that out.
The easiest thing is probably to make a Maven project that includes the versions of the libraries that you think you need and then use:
mvn dependency:tree -Dverbose
to print out what everything has actually been resolved to. Then you can look through that and search for “surprising” variations. (An example is in the Maven dependency plugin documentation.)
Once you've identified a clash, you resolve it by defining which dependency to use in a <dependencyManagement> section. Mostly this is easy, but sometimes it isn't.
Some IDEs may have support for doing this dependency resolution process — I know that Eclipse does — and that can make it substantially easier than doing it manually.
Related
I just started out learning spring boot and I can immediately see that there are two types of dependencies, at least those I have encountered,those labelled starter and those that are not. My question is what is the difference and when should I use one over the other.
The starter dependencies are just dependencies that contain a bunch of transitive dependencies. Try to Ctrl + Click them, you will see what other dependencies they contain.
Spring has packaged these dependencies to make your life easier and make you able to add all common dependencies needed to do certain tasks.
This is all based on their motto of convention over configuration.
The short answer is that those "starter" packages are autoconfigurable. They don't need any particular configuration to work out of the box, but you may configure them to fit your particular needs, which makes them perfect for the Spring Boot's focus on simplicity.
Those dependencies are thought to be used with Spring Boot, but the others were/are there for Spring (non Boot) projects. I haven't really dived in to them to pinpoint specific differences, but they pretty much work the same (I've successfuly build and run projects with autoconfigurable dependencies in Spring non Boot projects, but take that with a grain of salt, as those were practice projects in controlled environments).
Ideally you'd want to use 'regular' dependencies with non Boot projects and you'd want to use 'starters' for Boot projects, but it is not a hard rule. Just make sure to use properly mantained dependencies.
I am trying to balance time and avoid stepping on mines, on one side we have artifactory which is gradle based and need corresponding work to integrate with maven/gradle plugin(preferably with latter as most of our projects are gradle based) on another side all spring boot default starters in source are pom.xml + I only found single gradle custom repo:
https://github.com/web3j/web3j-spring-boot-starter in several pages of search results which uses gradle. But the build file looks pretty convoluted and includes a lot of maven parts.
I am happy to invest time into gradle if someone gives a green light with example/guide/share experience. Thanks. Just to understand if there is some particular reason why the situation is like that or I am afraid of ghosts?
A Spring Boot starter is a jar file containing some compiled classes and, typically, a META-INF/spring.factories file that lists some auto-configuration classes. As such, they can be built equally well with Maven or Gradle. Spring Boot's own starters are built with Maven purely because that's the build system that the whole project uses. If we were starting again from scratch now, we'd probably chose Gradle over Maven.
Some of the third-party starters listed here are build with Gradle, for example:
azure-application-insights-spring-boot-starter
charon-spring-boot-starter
session-couchbase-spring-boot-starter
I am using the latest (by the time of writing) Spring-Boot-starter-data-jpa (version 1.2.6.RELEASE). I find it actually uses the Spring-data-jpa version 1.7.3.RELEASE, which is considerably behind the latest (1.9).
Is it a supported approach to upgrade individual dependencies such as the Spring-data-jpa? If I do this myself, for example, by declaring a direct dependency on the wanted newer version (may just override the version properties), any side effect you guys foresee?
The reason why I am doing this is that I need to use a special parameter in this annotation:#EnableJpaRepositories(repositoryBaseClass = JpaRepositoryWithI18n.class)
That is not available in the supplied 1.7.3 jpa library.
Any workaround would be appreciated too.
Thanks
EDIT:
I tested the following two ways: 1) declared a direct dependency to Spring-JPA-data 1.9.0 and excluded it from spring-boot-starter-data-jpa 2) upgrade Spring-boot-web-starter to 1.3.0m5
2) worked out well for me. This is also what dunni's answer suggested.
I have not tested Andi's answer as this is a new project, we could easily upgrade the entire spring boot and regression test it without worrying too much about side-effects.
But I can see Andi's answer is an easier approach than 1). More importantly, it shows how you can upgrade other dependencies independently -- just overide the versions in parent pom.
Thanks
Spring Data JPA 1.9 is part of the Spring Data Gosling release train. As described in the Gosling announcement you can use it with Spring Boot 1.2:
To upgrade to the new release train use the BOM we ship as described in our examples repository and configure its version to Gosling-RELEASE. If you’re using Spring Boot, upgrading to the release train is as easy as setting the Maven property spring-data-releasetrain.version to that version. Note, that to use Spring Data REST with Boot 1.2, you also need to upgrade to Spring HATEOAS 0.19.0.RELEASE (by setting the spring-hateoas.version property) and Jackson 2.5 or better (current 2.6.1 preferred, via the jackson.version property).
In short, add this to your pom:
<properties>
<spring-data-releasetrain.version>Gosling-RELEASE</spring-data-releasetrain.version>
</properties>
It's not supported in that matter, that the Spring Boot test cases don't include newer versions. So your application might work with the newer version, but there may be some errors. With minor releases it's more likely to work without problems than with major version upgrades. You can also upgrade Spring Boot to 1.3.0.M5 (you should note however, that this is a milestone version, not yet the release).
I inherited a legacy Java Servlet webapp I am slowly rewriting into something a bit more modern.
The webapp runs a nightly scheduled task thanks to Quartz and depends on these library files:
quartz-1.8.0.jar
quartz-all-1.8.0.jar
I don't know Quartz, but I learned JUST enough to fix a harmless exception it was throwing when I took over the webapp. From that experience I learned that there have been significant API changes since version 1.8. 0. Someday when I finish rebuilding more vital parts of the webapp I want to take the time to learn quartz and fully update the libraries.
For now I would be happy to learn what Maven tags I would add to my pom.xml to get both of those jars.
When I boot up WebLogic 11g I get a message telling me that there is a Quartz 1.8.5. Is 1.8.5 fully compatible with version 1.8.0 ?
If so what would be the Maven tags I would need to upgrade to that?
Thanks much in advance for any information.
Steve
Maven Tag for Quartz,
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.5</version>
</dependency>
Yes, 1.8.5 is fully compatible with version 1.8.0.
Cheers!!!
First i would search in Maven central for those artifacts like this:
http://search.maven.org/#search|gav|1|g%3A%22org.quartz-scheduler%22%20AND%20a%3A%22quartz%22
For quartz-all seemed to be not existing in the given version.
http://search.maven.org/#search|ga|1|quartz-all
I would assume that you only need the quartz artifact and not quartz-all.
Hello I am new to the Spring and maven world, and I want to know what is the difference between this 2 dependencies?
Its a simple question.. I am having trouble with my pom.xml file, so I want to know everything :).
Thanks in advance.
These are actually 2 of many Spring Framework modules. You can easily find what packages these artifacts contain, using this site:
http://mvnrepository.com/artifact/org.springframework/spring-core/3.1.1.RELEASE
This can give you information about classes contained within a particular artifact and probably about the its purpose.
For Spring Framework, spring-core contains mainly core utilities and common stuff (like enums) and because it's really critical for Spring, probably all other Spring modules depend on it (directly or transitively).
In turn spring-context provides Application Context, that is Spring's Dependency Injection Container and it is probably always defined in POMs of artifacts that use Spring Framework somehow. In fact, spring-context depends on spring-core so by defining spring-context as your dependency, you have spring-core in your classpath as well.