I have a project in Eclipse (Helios), with Maven pom.xml.
My project is a web app that will use Hibernate, MySQL.
But i have endless woes in getting pom.xml right. I am new to maven, and can't believe setting up dependencies is so tough(do others have similar expierience / or am i dumb).
My pom.xml is here:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyProj1</groupId>
<artifactId>MyProj1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>Scala Tools</id>
<name>Scala Tools</name>
<url>http://scala-tools.org/repo-releases/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.4.Final</version>
</dependency>
<!--
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.6.4.Final</version>
</dependency>
-->
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.6-brew</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1-jboss</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.16</version>
</dependency>
</dependencies>
</project>
The error i get is:
Missing artifact commons-logging:commons-logging:jar:1.1.1:compile
Missing artifact org.hibernate:hibernate-entitymanager:jar:3.6.4.Final:compile
Missing artifact javassist:javassist:jar:3.12.0.GA:compile
Missing artifact org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
Missing artifact org.slf4j:slf4j-api:jar:1.6.1:compile
Missing artifact org.hibernate:hibernate-core:jar:3.6.4.Final:compile
Missing artifact commons-collections:commons-collections:jar:3.1:compile
Missing artifact org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
Missing artifact javax.transaction:jta:jar:1.1:compile
Missing artifact antlr:antlr:jar:2.7.6-brew:compile
Missing artifact dom4j:dom4j:jar:1.6.1-jboss:compile
Missing artifact xml-apis:xml-apis:jar:1.0.b2:compile
Missing artifact asm:asm:jar:1.4.3:compile
Missing artifact cglib:cglib:jar:2.1.1:compile
---
All the above errors go away, if i remove the mysql dependency from the pom.xml file.
I am totally confused why mysql should have dependency on these.
Isn't Maven supposed to resolve these dependencies automatically? Afterall isn't that the whole idea of using Maven.
Experts please guide me in the right direction.
You can search for dependencies here:
http://mvnrepository.com
For Maven2 it is:
http://repo1.maven.org/maven2/
Hibernate in particular is notoriously difficult for setting up the right dependencies.
See: How can I use Maven to get the latest Hibernate release?
Related
I am calling keycloak api in my project using below code. It is working in Keylcloak 7.0.1. But, it is not working RedHat SSO 7.3.0.GA
Keycloak kc = KeycloakBuilder.builder()
.realm(MASTERREALM)
.username(USERNAME)
.password(PASSWORD)
.serverUrl(SERVER_URL).clientId(CLIENT_ID)
.resteasyClient(new ResteasyClientBuilder().connectionPoolSize(10).build()).build();
UsersResource usersResource = kc.realm(REALM).users();
This is working fine when connecting to Keycloak 7.0.1 using below dependencies
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-common</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.7.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.7.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.7.0.Final</version>
</dependency>
<!-- Keycloak api dependencies -->
List<UserRepresentation> listUserResource = usersResource.search(strUserName);
My questions:-
1) when I try to connect Red Hat SSO 7.3.0.GA what dependencies I have to use.
I have tried use below dependency. it is throwing maven build error of dependencies are not available in central repository. Since, This artifact is located at Redhat GA repository.
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>7.0.0.redhat-00002</version>
</dependency>
2) How to define Redhat GA repository in pom.xml file
Thanks in advance
From the RedHat docs, include the following in your ~/.m2/settings.xml file:
<!-- Configure the JBoss Enterprise Maven repository -->
<profile>
<id>jboss-enterprise-maven-repository</id>
<repositories>
<repository>
<id>jboss-enterprise-maven-repository</id>
<url>https://maven.repository.redhat.com/ga/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-enterprise-maven-repository</id>
<url>https://maven.repository.redhat.com/ga/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
assuming that you have access to the JBoss EAP Maven repository. You'll need to either enable the jboss-enterprise-maven-repository profile on the command line with mvn -Pjboss-enterprise-maven-repository <target> or by adding:
<activeProfiles>
<activeProfile>jboss-enterprise-maven-repository</activeProfile>
</activeProfiles>
to your ~/.m2/settings.xml file.
I learn JPA from https://spring.io/guides/gs/accessing-data-jpa/#initial and git clone project
I did a java file following this example but it is still error.
How can I fix it?
-----------
-----------
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-06-09 16:41:37.706 ERROR 18872 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
---------
---------
pom.xml file
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
<groupId>org.springframework</groupId>
<artifactId>gs-accessing-data-jpa</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>org.jboss.repository.releases</id>
<name>JBoss Maven Release Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
You used spring-boot-starter-data-jpa in your pom.xml. But I guess, no data source adjusted in appllication.properties file. If you wanna use DB connections, application.properties file should contain configurations like this:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=mysqluser
spring.datasource.password=mysqlpass
spring.datasource.url=jdbc:mysql://localhost:8080/myDb?createDatabaseIfNotExist=true
Otherwise if you don't use jpa, remove spring-boot-starter-data-jpa dependency from pom.xml:
remove:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
And then try again to run the application.
Discovered that to use Spring Data ElasticSearch with ElasticSearch 5.5.0 that you need to use Spring Boot's 2.0.0.M2 milestone... However, something is wrong with my pom where maven can't seem to find the Spring Boot 2.0.0.M2 milestone from the Maven repositories that I specified.
pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M2</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- Elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.0.0.M2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<version>2.0.0.M2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Package as an executable jar/war -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-libs-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>http://repo.spring.io/libs-snapshot</url>
</repository>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
Received the following problem when doing a Maven -> Update Project in Eclipse:
Maven pom Loading Problem: Could not find artifact org.springframework.boot:spring-boot-maven-plugin:jar:2.0.0.M2 in spring-releases (https://repo.spring.io/libs-release) pom.xml
For milestone versions you have to add the milestone repository with the URL https://repo.spring.io/libs-milestone/.
I'm new to Maven and am trying to create a simple Maven project given in geotools.org
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- use the latest snapshot -->
<geotools.version>17-SNAPSHOT</geotools.version>
</properties>
<groupId>org.geotools</groupId>
<artifactId>tutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>tutorial</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>${geotools.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>boundless</id>
<name>Boundless Maven Repository</name>
<url>http://repo.boundlessgeo.com/main</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
The error I am getting is 'Offline / Missing artifact org.geotools:gt-shapefile:jar:17-SNAPSHOT'. How do I resolve this? I am using Eclipse Neon.1a Release (4.6.1).There is no option for selecting Project ‣ Update All Maven Dependencies. In some of the similar questions asked here it was recommended to change the repository URL. Which URL shall I change? Java.net repository OR Open Source Geospatial Foundation Repository OR Boundless Maven Repository?
It looks like the Boundless artifactory was down at that moment. For the time being you can use version 16-RC1 as the latest released version, 15.2 as the last stable release.
If you absolutely must be on the cutting edge, I'd recommend downloading/cloning master and building it locally.
I think that instead of ${geotools.version} you should place a real version number of the project, like 15.1
I am not sure though if that's the problem
Also, you might want to consider changing to Gradle build. I think it is a lot simpler
I'm new to maven and drools, so this could be obvious...
I'm trying to work off of the drools snapshot repository using maven/eclipse. I'd like to be able to link the sources/javadoc when updating using maven but I keep getting messages similar to:
Can't download java-source for artifact org.drools:drools-process-task:5.1.0.20091223.193911-177
Any idea what I'm doing wrong?
I created a simple project to reproduce this error and, using the following pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>maven-drools-testcase</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>maven-drools-testcase</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>repository.jboss.org</id>
<url>http://repository.jboss.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots.jboss.org</id>
<url>http://snapshots.jboss.org/maven2</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<!--
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-process-task</artifactId>
<version>5.1.0.M1</version>
</dependency>
-->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-process-task</artifactId>
<version>5.1.0.SNAPSHOT</version>
</dependency>
</dependencies>
</project>
I wasn't indeed able to download the sources from eclipse (which are in the repository!). This works fine with version 5.1.0.M1 though so there must be a problem with the JBoss Snapshots Repository (maybe the metadata?). You should open an issue at Drools Jira.
UPDATE: I did a bit more testing and, strangely, if I add the following dependency in the pom.xml:
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-process-task</artifactId>
<version>5.1.0.SNAPSHOT</version>
<classifier>sources</classifier>
</dependency>
The sources JAR gets properly downloaded.
As I said, I'm don't know exactly what is the root cause of the problem and wonder if this is not a problem with m2eclipse after all. Actually, you should maybe try to open an issue in M2Eclipse Jira first and see if they detect a problem with their code or with the JBoss Snapshot repository (in which case they will send you to Drools Jira I guess).
Before drools 5.2.0.Final (released 2 years ago), the maven poms were a mess and source jars didn't get uploaded correctly. That's fixed in 5.2, 5.3, 5.4, 5.5, ...
Upgrade to drools 5.5.0.Final.