spring use library version not in the mvn repository - spring

I'm trying to use spring-session-jdbc:2.0.0.RC2 which is not listed in https://mvnrepository.com/artifact/org.springframework.session/spring-session-jdbc/1.3.1.RELEASE
spring session github has newer version than mvnrepository.
How can I add the dependency of the new version in the pom.xml file?

To obtain dependencies that aren't on the central mvn repository, you must communicate to your project that you need it to point to an additional repository. In your case, this snippet, added to your pom, should do:
<repositories>
<repository>
<id>spring-milestone-repository</id>
<name></name>
<url>http://repo.spring.io/milestone/</url>
</repository>
</repositories>
After declaring this, you just add this to your dependencies, and it will be downloaded:
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
<version>2.0.0.M2</version>
</dependency>

Related

mvn- look for wrong url in maven repositories

When I run mvn package to compile a maven project it downloads the jar file from
wrong URLs. It adds org/dnosproject/ to the URL which is wrong.
Downloading: https://mvnrepository.com/artifact/io.github.dnos-project/dnos-lib-all/org/dnosproject/onos-port-protobuf/1.1.5/onos-port-protobuf-1.1.5.jar
<repositories>
<repository>
<id>dnos-lib-all</id>
<name>dnos-lib</name>
<url>https://mvnrepository.com/artifact/io.github.dnos-project/dnos-lib-all</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.github.dnos-project</groupId>
<artifactId>dnos-lib-all</artifactId>
<version>1.1.5</version>
</dependency>
The website mvnrepository.com is a kind of search engine across multiple real Maven repositories. If you look at the link you mentioned in your <repository/> configuration, you'll notice they list that dependency as available in "Central", in fact here. "Central" is configured by default, so you don't need a <repository/> configuration for this dependency. Instead, you just need the correct <dependency/> entry:
<dependency>
<groupId>io.github.dnos-project</groupId>
<artifactId>dnos-lib-all</artifactId>
<version>1.1.5</version>
</dependency>
You already had this in the snippet you posted, so just removing the <repository/> configuration should do the trick.

Why do I need PrimeFaces Maven Repository to use a theme?

Why do I need PrimeFaces Maven Repository, when using all-themes dependency from PrimeFaces?
When I just use one dependency I got no errors and can work.
But when I use all-themes I get missing artifact org.primefaces.themes:all-themes.jar:1.0.10, but why?
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.10</version>
</dependency>
Maven's default repository is "maven central". There are a lot of artifacts in there, but some vendors may not have put their artifacts there and primefaces is one of them. Maven will look for the jar in maven central and won't find it. If you don't specify that it should also look in the Primefaces Maven Repository (which does have the artifact), it can't find the artifact.
The PrimeFaces people have decided not to deliver their packages into Maven central so that's the reason why you need to define the prime faces repository separately.
For such purposes it's a good idea to start using a repository manager which can be configured in a central location for your company to use PrimeFaces repository as well. This will make life easier.
Question:
But when I use all-themes I get missing artifact org.primefaces.themes:all-themes.jar:1.0.10, but why?
Answer:
Because the version of PrimeFaces all-theme you are using it does not exist in Maven repo. Currently Maven has 1.0.8 version as latest.
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.8</version>
</dependency>
Maven Repo
Alternatively, you can use single themes from Icefaces
<dependency>
<groupId>org.icefaces.ace-themes</groupId>
<artifactId>ace-sunny</artifactId>
<version>4.1.0</version>
</dependency>
In your XHTML page include the style:
<h:outputStylesheet name="theme.css" library="ace-sunny"/>
We can only guess why this solution was chosen back then. Currently there is no need to a custom repository for themes. They are simply built-in, or, in case of premium themes, you will need to add the resources to your project yourself.
See https://primefaces.github.io/primefaces/12_0_0/#/core/themes

maven repository setup not working

I am referencing a repository in my POM.xml to add the ojdbc.jar to my project but Maven (I use the STS plugin) keeps telling me it can't find the jar.
I am showing below my repositories and jar dependency as defined in my POM.xml.
Anyone has an idea as to why the jar can't be found? Is my POM.xml not setup properly?
Note the vaadin repo works fine as the vaadin jars are correctly added to my project.
<repositories>
<repository>
<id>myrepo</id>
<url>http://mvnrepository.com/</url>
</repository>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
and here is the dependency setup as defined at http://mvnrepository.com/artifact/ojdbc/ojdbc/14:
<dependencies>
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
</dependency>
</dependencies>
Anyone has an idea as to why the jar can't be found?
The jar can't be found due to license constraints.
Is my POM.xml not setup properly?
No it isn't, but adding to your pom the dependency:
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
</dependency>
you are able to download only the ojdbc14 pom because it has not a license limitation about distribution.
In order to make the above dependency works the jar has to be manually installed into your local Maven repository, without violating the license, by running:
mvn install:install-file -Dfile={Path_to_your_ojdbc.jar} -DgroupId=ojdbc
-DartifactId=ojdbc -Dversion=14 -Dpackaging=jar
eventually changing to the appropriate version number in -Dversion attribute, as correctly suggested by user1570577.
To use Oracle jdbc(OJDBC) driver with Maven, you can download the jar to your local machine and install it manually into your Maven local repository.
After downloading the jar install using the following command :
mvn install:install-file -Dfile={Path_to_your_ojdbc.jar} -DgroupId=com.oracle
-DartifactId=ojdbc -Dversion=14 -Dpackaging=jar . If the version is less than 14 change the appropriate version number in -Dversion attribute
Now you can set the dependency details in the pom file :
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
</dependency>
</dependencies>
Oracle now has a maven repository: maven.oracle.com
See https://blogs.oracle.com/WebLogicServer/entry/weblogic_server_and_the_oracle

Error in pom.xml when adding sauce labs dependencies

I am getting errors when I add sauce labs dependency in my pom xml.
<dependency>
<groupId>com.saucelabs</groupId>
<artifactId>sauce_testng</artifactId>
<version>1.0.19</version>
</dependency>
Is any one seeing the same issue?
The artifact is stored in the Sauce Labs Maven repository, can you add the following into your pom.xml file?
<repositories>
<repository>
<id>Sauce Maven Repository</id>
<url>https://repository-saucelabs.forge.cloudbees.com/release</url>
</repository>
</repositories>
The artifact that you are referring to is not in central. Are you sure that you have the info?
I have found this info
<dependency>
<groupId>com.saucelabs</groupId>
<artifactId>sauce-rest-api</artifactId>
<version>1.1</version>

Maven build issue with Hibernate for Windows

I'm getting build errors for for my Maven enabled project related to the Hibernate extension. - It's a very basic app, and I was able to solve this issue on my Linux box by manually installing some required artifacts:
mvn install:install-file -DgroupId=javassist -DartifactId=javassist
-Dversion=3.9.0 -Dpackaging=jar -Dfile=foo.jar
That worked out (Hibernate as a set of required deps).
But in case of Windows things are different. How do I add the dependencies manually to Maven on Windows?
1) org.hibernate:hibernate:jar:3.3.2
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.hibernate -DartifactId=hibernate -Dversion=3.3.2
-Dpackaging=jar -Dfile=/path/to/file
2) javassist:javassist:jar:3.9.0
Can I automate this cumbersome manual dependency installation for my coworkers on their Windows machines? Are there any helpful tools or GUI that can perform these tasks? The best way would be that Maven does it all automatically. I'm not too familiar with it jet.
Thanks for answers.
Firstly, you can manually install artifacts to your local Maven repository in Windows in exactly the same way you did on your Linux box.
Ideally, as you say, Maven will do the hard work for you. Usually you won't have to install jars manually: for most libraries Maven will know what dependencies each jar has. By default, Maven will check the central repository, and a couple of others. To access jars in other repositories, just add them to your POM, as follows:
<project>
...
<repositories>
<repository>
<id>jboss.maven2.repo</id>
<name>JBoss Maven Repo</name>
<url>http://repository.jboss.com/maven2</url>
</repository>
<!-- other repositories here -->
</repositories>
...
</project>
The JBoss repo mentioned above is a good one to add. It has a lot of common jars, including the jars for the hibernate version you mentioned above. Reference it in your pom.xml like this:
<dependencies>
<!-- ... -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
</dependency>
</dependencies>
Once you have added these dependencies, Maven will also download the libraries that these libraries depend on, and so on (including the Javassist library in your example).
Finally, as mentioned in another answer, if you have a lot of third party libraries to install for your project that don't exist in other repositories, you might want to install a repository manager like Nexus, Artifactory, or Archiva, which will allow you to perform the install commands you mentioned, through a web-based interface.
You can use mvn install:install-file on your Windows machine to install dependencies to the local repository as well
You might want to change your settings.xml to add additional repository mirrors, so you aren't relying on just central. Check out jboss, java.net, etc. You can also set up your own repository manager (like Nexus) to handle mirroring, storing your team's artifacts, etc.; and then just point each developers machine at your repository.
See Repository Management with Nexus and Reasons to use a Repository Manager for more.
I was able to solve this issue on my Linux box by manually installing some required artifacts (...)
Manually installing an artifact is a bad practice (it makes your build non portable as you're experiencing) and, actually, there is no reason to install the artifacts you're looking for manually, they're both available in the JBoss repository. So, add it to the list of "declared" repositories:
<project>
...
<repositories>
<repository>
<id>repository.jboss.org</id>
<name>Jboss Repository for Maven</name>
<url>http://repository.jboss.org/maven2</url>
</repository>
</repositories>
...
</project>
And then declare the following dependencies:
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.9.0.GA</version>
</dependency>
</dependencies>
Note the dependency on hibernate-core (http://repository.jboss.org/maven2/org/hibernate/hibernate/3.3.2.GA/ contains only a pom).

Resources