I've started to create a java project using the dropwizard framework and maven. My pom.xml file looks like
<?xml version="1.0" encoding="UTF-8"?>
<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>org.dexcane</groupId>
<artifactId>dexcane-backend</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<dropwizard.version>2.1.4-SNAPSHOT</dropwizard.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/io.dropwizard.archetypes/dropwizard-archetypes -->
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>2.1.4-SNAPSHOT</version>
<type>pom</type>
</dependency>
</dependencies>
</project>
I'm following the dropwizard tutorial. When I hover over the "2.1.4-SNAPSHOT" dependency Intellij says "Dependency 'io.dropwizard:dropwizard-core:2.1.4-SNAPSHOT' not found ". Does anyone know what's wrong with the import? The tutorial says the current version of dropwizard is 2.1.4-SNAPSHOT.
You shouldn't add it with the type of pom as its packaging is jar.
Related
I am new to spark and is trying to build a simple project in java with IDEA. This test project simply read txt file as javaRDD and display its content.
When I am trying to build my project, I got error
java: cannot access scala.Cloneable
class file for scala.Cloneable not found
at line
SparkConf conf = new SparkConf().setAppName("test_app").setMaster("local[*]");
and
java: cannot access scala.Serializable
class file for scala.Serializable not found
at
for(String line:lines.collect()){
System.out.println(line);
}
From my understanding this means IDEA do not have scala dependency. However, in my pom file, spark dependency shows
Dependency 'org.apache.spark:spark-core_2.13:3.3.1' not found
My pom.xml looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<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>org.example</groupId>
<artifactId>spark_test_project</artifactId>
<version>1.0</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spark.version>3.3.1</spark.version>
<java.version>11.0.16</java.version>
<scala.version>2.11.12</scala.version>
<java.compat.version>11.0.16</java.compat.version>
</properties>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.13</artifactId>
<version>3.3.1</version>
</dependency>
</dependencies>
</project>
How should I solve this issue?
I tried to install jar dependency manually in IDEA but this would not solve the issue. My current scala version is 2.11.12.
I have a project, where I use spring-cloud-starter-stream-rabbit. But our devOps team asked me why I'm using spring-web. I've figured out that spring-web goes exactly from spring-cloud-starter-stream-rabbit. But there is no version defined:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
I've started to look in parent projects. But with no result.
pom hierarchy
I go from bottom to top:
spring-cloud-stream-binder-rabbit-core.pom
spring-cloud-stream-binder-rabbit-parent.pom
spring-cloud-build.pom
Surprisingly I cant find version there. I thought maybe this versions goes from other dependencies. Created project with single dependency like this
<?xml version="1.0" encoding="UTF-8"?>
<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>org.example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>3.1.2</version>
</dependency>
</dependencies>
</project>
But mvn dependency:list showed:
...
[INFO] com.fasterxml:classmate:jar:1.3.4:compile
[INFO] org.springframework:spring-web:jar:5.3.4:compile
[INFO] javax.annotation:javax.annotation-api:jar:1.3.2:compile
...
Wow! Where is that secret place where maven gets version for spring-web? If you know please help.
Thanks for support!
The title says it all really, my pom is shown below:
<?xml version="1.0" encoding="UTF-8"?>
<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>org.example</groupId>
<artifactId>CouncillorsApp</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.6</version>
</dependency>
</dependencies>
</project>
The following error is given:
"Dependency 'org.mongodb:mongodb-driver-sync:3.10.2' not found"
I'm using Java 14.0.2 and the latest version of IntelliJ
please read installation
you can try this
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.12.6</version>
</dependency>
</dependencies>
So after restarting IntelliJ the above code seems to work fine. I'm unsure of where the issue was, but the dependency is being found now without any changes to the pom.
We have a multi module project where we define several dependencies in parent pom under dependencyManagement tag to manage dependencies version.
It works fine for several modules but one.
Parent pom
<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>my.org.product</groupId>
<artifactId>product-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<parade-web.version>2.0.0</parade-web.version>
<!-- other properties -->
</properties>
<modules>
<module>../ProductWeb</module>
<!-- other modules -->
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>my.org.parade</groupId>
<artifactId>ParadeWeb</artifactId>
<version>${parade-web.version}</version>
</dependency>
<!-- other dependencies -->
</dependencies>
</dependencyManagement>
</project>
ProductWeb pom
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>my.org.product</groupId>
<artifactId>product-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../productparent</relativePath>
</parent>
<artifactId>ProductWeb</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency> <!-- 'dependencies.dependency.version' for my.org.parade:ParadeWeb:jar is missing. -->
<groupId>my.org.parade</groupId>
<artifactId>ParadeWeb</artifactId>
<type>war</type>
</dependency>
<!-- other dependencies -->
</dependencies>
</project>
If I add <version>${parade-web.version}</version> in my ProductWeb pom, NetBeans warns me that
Overrides version defined in DependencyManagement. The managed version is 2.12.2-RELEASE.
The only difference between this dependency and the other is the war type, but I don't get why dependency management fails to sets its version.
UPDATE
I managed to omit version tag but I needed to add <type>war</type> on both parent and child.
I don't understand. Does parent try to resolve dependency version looking for a war but then doesn't pass it through its children?
Add <type>war</type> to the dependencyManagement. This should do the trick.
My pom.xml file:
<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>com.name.MyProject</groupId>
<artifactId>MyProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>example-jetty-embedded</artifactId>
<version>9.1.0.v20131115</version>
</dependency>
</dependencies>
</project>
and I got a problem:
Missing artifact
org.eclipse.jetty.tests:test-mock-resources:jar:9.1.0.v20131115
I see that mvnrepository does not contain this jar file (http://mvnrepository.com/artifact/org.eclipse.jetty.tests/test-mock-resources)
How can I fix this problem?
Test resources are not deployed to maven central by the Jetty project.
And example projects are usually not considered dependencies.