I'm new to Maven and AWS and I don't really understand where I'm going wrong or even where to get help here.
File:
import com.amazonaws.services.s3.AmazonS3EncryptionClientV2Builder;
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>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>com.example.myapp</groupId>
<artifactId>myapp</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>myapp</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.15.15</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.327</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I run mvn package I get:
cannot find symbol
symbol: class AmazonS3EncryptionClientV2Builder
location: package com.amazonaws.services.s3
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.878 s
[INFO] Finished at: 2021-02-04T16:38:20-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp: Compilation failure
[ERROR] /Users/LukeGarratt/myapp/src/main/java/com/example/myapp/App.java:[23,33] cannot find symbol
[ERROR] symbol: class AmazonS3EncryptionClientV2Builder
[ERROR] location: package com.amazonaws.services.s3
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I am just so confused. What am I doing? What do I need to add in pom.xml? Where? Why? How can I find that out in general? What doe this error even mean? Thanks
You are using the older AWS Java V1 library. Its recommended to use AWS SDK for Java V2. As you are new to AWS, I recommend that you start here:
Get started with the AWS SDK for Java 2.x
Follow that topic exactly and you will get Amazon S3 Java V2 examples running. Follow these steps to complete this tutorial:
Step 1: Set up for this tutorial
Step 2: Create the project
Step 2: Step 3: Write the code
Step 4: Build and run the application
Now for your next question about Maven. Maven is an easy way to pull in the Java libs you require to compile Java projects. For more about Maven (including the role of the POM file), see this topic:
Maven in 5 Minutes
All Java AWS Service examples have a corresponding POM file in the Github repository. For example, if you want to run Amazon S3 Java V2 examples, you need to get the POM file dependencies located here:
https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/example_code/s3
Likewise, if you want to build the Amazon DynamoDB V2 examples, you need to include the POM dependencies located here:
https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/example_code/dynamodb
Every service in the Java V2 GitHub repo has a corresponding POM file with the dependencies you need to build the corresponding AWS Service examples. By adding these dependencies to your POM file, you no longer have to locate and download JAR files over the internet and manually add them to your project's Class path.
Your error is because you are using V2 POM dependencies to compile V1 code. This is V2:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.15.15</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
V2 Java packages starts with software.amazon.awssdk.services and V1 starts with com.amazonaws.services.s3. That is a quick way you can tell the difference. Mixing up V1 and V2 will always result in errors.
To learn how to code with the AWS V2 Java API, please refer to the AWS Java V2 Developer Guide here:
Developer guide - AWS SDK for Java 2.x
That class you are looking for com.amazonaws.services.s3.AmazonS3EncryptionClientV2Builder is V2 Encryption for S3. Here it is
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.948</version>
</dependency>
This is an example from Aws Docs.
Related
I am new to maven and junit. I have tried to build a maven project through which I want to try the kubernetes official java client api examples. While compiling the pom.xml file encountered an error. I am trying to run the maven project using command line. In order to compile the pom.xml file I have used "mvn clean package install"
<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>ocp</groupId>
<artifactId>DemoTest</artifactId>
<version>14.0.1</version>
<packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven-plugin-version>1.0.0</maven-plugin-version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>
<dependencies>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-api</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-proto</artifactId>
<version>14.0.0</version>
<scope>compile</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
</plugins>
</build>
</project>
Error:-
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /mnt/d/junit/test/new/DemoTest/src/main/java/ocp/App.java:[3,28] package io.kubernetes.client does not exist
[ERROR] /mnt/d/junit/test/new/DemoTest/src/main/java/ocp/App.java:[4,28] package io.kubernetes.client does not exist
[ERROR] /mnt/d/junit/test/new/DemoTest/src/main/java/ocp/App.java:[5,28] package io.kubernetes.client does not exist
[ERROR] /mnt/d/junit/test/new/DemoTest/src/main/java/ocp/App.java:[6,33] package io.kubernetes.client.apis does not exist
[ERROR] /mnt/d/junit/test/new/DemoTest/src/main/java/ocp/App.java:[7,35] package io.kubernetes.client.models does not exist
[ERROR] /mnt/d/junit/test/new/DemoTest/src/main/java/ocp/App.java:[8,35] package io.kubernetes.client.models does not exist
[ERROR] /mnt/d/junit/test/new/DemoTest/src/main/java/ocp/App.java:[9,33] package io.kubernetes.client.util does not exist
[ERROR] /mnt/d/junit/test/new/DemoTest/src/main/java/ocp/App.java:[14,64] cannot find symbol
symbol: class ApiException
location: class ocp.App
[ERROR] /mnt/d/junit/test/new/DemoTest/src/main/java/ocp/App.java:[15,9] cannot find symbol
symbol: class ApiClient
location: class ocp.App
[ERROR] /mnt/d/junit/test/new/DemoTest/src/main/java/ocp/App.java:[15,28] cannot find symbol
symbol: variable Config
location: class ocp.App
Please suggest what have I missed.
You don't need dependency of type "pom" - just remove this line and try to rebuild.
Maven will try to "bring" the dependency (by downloading it from the centralized repo) to your classpath. In java dependencies like this are jars.
So that's the problem I believe
Also, compile is a default scope anyway, so you can omit it.
In addition, project.version points on the version of your product, probably you want a specific version of the dependency, like 14.0.1 (the last version available in maven central)
It might be a coincidence, but your own project also has the same version (14.0.1) exactly. I don't see a reason to do so, you can start your project with your own version that has nothing to do with k8s java client's version)
For example you can use 1.0-SNAPSHOT
An example of the dependency definition (of k8s java client as you've stated in the question title) is:
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-api</artifactId>
<version>14.0.1</version>
</dependency>
The rest of the dependencies in the presented pom also should be fixed in a similar way.
I have a serverless aws / java project (simple hello world type).
I can compile and build the application fine, but when I do a 'Deploy Serverless Application' on my template.yaml using IntelliJ IDE, I get a maven build error:
Build Failed
Error: JavaMavenWorkflow:MavenBuild - Maven Failed: [INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for com.amazonaws:aws-lambda-java-events:jar is missing. # line 46, column 21
[ERROR] 'dependencies.dependency.version' for com.amazonaws:aws-java- sdk:jar is missing. # line 52, column 21
My pom.xml is as follows for those two dependencies. I also use DependencyManagement:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.11.651</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
</dependency>
I could revert to using < version > tags again but then the rest of my application won't build due to the other dependencies I have. Also, I find using aws-java-sdk-bom a clean way of managing dependencies without needing to worry about versions and compatibility.
Checking on the pom.xml file of aws-jafa-sdk-bom on https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-bom/pom.xml
The dependencies "aws-lambda-java-events" and "aws-java-sdk" are not defined.
You should add the version number, for example:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>2.2.7</version>
</dependency>
Also, I haven't seen "aws-java-sdk" as a dependency anywhere.
I have three very simple applilcations. One is COMMON which I will center security configs, other with ZUUL feature and the third is a EUREKA SERVER. Both are Spring Boot and Java 11. Although I am using Java 11 I am not reling on modularity (as far as I know it will not make sense use modularity feature with Spring Boot).
When I run all three in Eclipse I successfully can run the server, common and zuul in that sequence. When I try to maven build I get the error mentioned in subject.
The immediate explanation would be "you don't have common in zuul classpath". Well, as far as I check I do have common in zuul classpath. I am wondering if there is any extra config because I am using Java 11 but not using modularaty.
By saying I am using Java 11 but not modularity I mean, I have Java 11 but I don't have module-info.java at all in any of the three projects.
Checking in .m2 folder and unzip the common.jar I do see the class complained.
Zuul project 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.test</groupId>
<artifactId>zuul</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>zuul</name>
<description>Zuul project</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>com.test</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Evidence that common is the maven dependences
Error during mvn clean install:
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------------< com.test:zuul >----------------------------
[INFO] Building zuul 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # zuul ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # zuul ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\_d\WSs\soteste\zuul\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/_d/WSs/soteste/zuul/src/main/java/com/test/zuul/security/SecurityTokenConfig.java:[14,32] package com.test.common.security does not exist
[ERROR] /C:/_d/WSs/soteste/zuul/src/main/java/com/test/zuul/security/SecurityTokenConfig.java:[21,17] cannot find symbol
symbol: class JwtConfig
location: class com.test.zuul.security.SecurityTokenConfig
[ERROR] /C:/_d/WSs/soteste/zuul/src/main/java/com/test/zuul/security/SecurityTokenConfig.java:[46,16] cannot find symbol
symbol: class JwtConfig
location: class com.test.zuul.security.SecurityTokenConfig
[ERROR] /C:/_d/WSs/soteste/zuul/src/main/java/com/test/zuul/security/SecurityTokenConfig.java:[47,23] cannot find symbol
symbol: class JwtConfig
location: class com.test.zuul.security.SecurityTokenConfig
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.778 s
[INFO] Finished at: 2019-03-21T14:23:23-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project zuul: Compilation failure: Compilation failure:
[ERROR] /C:/_d/WSs/soteste/zuul/src/main/java/com/test/zuul/security/SecurityTokenConfig.java:[14,32] package com.test.common.security does not exist
[ERROR] /C:/_d/WSs/soteste/zuul/src/main/java/com/test/zuul/security/SecurityTokenConfig.java:[21,17] cannot find symbol
[ERROR] symbol: class JwtConfig
[ERROR] location: class com.test.zuul.security.SecurityTokenConfig
[ERROR] /C:/_d/WSs/soteste/zuul/src/main/java/com/test/zuul/security/SecurityTokenConfig.java:[46,16] cannot find symbol
[ERROR] symbol: class JwtConfig
[ERROR] location: class com.test.zuul.security.SecurityTokenConfig
[ERROR] /C:/_d/WSs/soteste/zuul/src/main/java/com/test/zuul/security/SecurityTokenConfig.java:[47,23] cannot find symbol
[ERROR] symbol: class JwtConfig
[ERROR] location: class com.test.zuul.security.SecurityTokenConfig
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
The class complained is in the jar
*** Edited
Common 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.test</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>common</name>
<description>Zuul project</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
That's because the common project is a Spring Boot Application (I see the BOOT-INF folder inside the generated jar).
From Use a Spring Boot Application as a Dependency documentation:
The executable archive cannot be used as a dependency as the
executable jar format packages application classes in BOOT-INF/classes.
This means that they cannot be found when the executable jar is used
as a dependency.
To produce the two artifacts, one that can be used as a dependency and
one that is executable, a classifier must be specified. This
classifier is applied to the name of the executable archive, leaving
the default archive for use as a dependency.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
Here is an example:
The first jar is build as dependency-able, the second one is Spring Boot executable.
That Eclipse is able to resolve Eclipse projects of the currently open workspace as Maven dependencies into other projects is a specialty of Eclipse.
If you execute Maven on command-line or from within Eclipse you leave the sphere of Eclipse and use plain Maven. Plain Maven (even the in Eclipse integrated Maven) does not know about Eclipse projects, it only knows the artifacts available in your local and the configured remote repositories.
Therefore the correct approach in your case is to first execute mvn install on your common project. This installs common into your local repo and makes it available to Maven.
Afterwards you can execute mvn clean install on your zuul project.
I followed a tutorial and get this dependency file in maven project in intelliJ IDEA 2018.3
My pom.xml
<?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>kafka.sample.firstProject</groupId>
<artifactId>kafka-first-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
<kafka.version>2.1.0</kafka.version>
</properties>
<build>
<plug
ins>
<!-- Maven Compiler Plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Apache Kafka Clients-->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Apache Kafka Streams-->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Apache Log4J2 binding for SLF4J -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.0</version>
</dependency>
<!-- JUnit5 Jupiter -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<!-- JUnit 5 Jupiter Engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<!-- JUnit 5 Jupiter Parameterized Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
but whenever i try to run my build it throws this:
Error:(3, 41) java: package org.apache.kafka.clients.producer does not
exist and so on ...
Even after trying to run maven build still the problem persist.
Believe it or not i have get stuck in this problem from last many days.
Edit:
As #Parsecer asked to show maven build log, i found that there is an error as well
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building kafka-first-sample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.329 s
[INFO] Finished at: 2019-02-20T09:10:30+05:00
[INFO] Final Memory: 7M/34M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): No such host is known (repo.maven.apache.org) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
Process finished with exit code 1
1) Check settings of IntelliJ by Ctrl-Alt-S. Type 'Maven' and see if you have proper Maven distribution (not the bundled one).
2) Refresh your Maven project from the right hand side of IntelliJ window.
This happens due to several issues which normally fixed after an IDE restart. Well you can try several things,
Do a maven reimport
Do a maven Download sources and documentation
And restart the JIdea IDE
You can try to use a latest maven version and see also.
My System was behind a Proxy which not allowing me to get these packages. I remove the proxy and now it is working fine.
I was trying to build an application using maven build.It was returning this build failure even though I have placed my pom.xml file is in-place.
I have configure my pom with out any issue.But I can see that there is some error returning related to schema.But don't have much information on that
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.amazon:amazon:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework.boot:spring-boot-starter-test:jar -> duplicate declaration of version (?) # line 65, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyApplication 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) # amazon ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) # amazon ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to /Users/Arun/Documents/SpringBoot/MyApplication/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.051 s
[INFO] Finished at: 2018-06-09T08:00:55-07:00
[INFO] Final Memory: 25M/220M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project amazon: Fatal error compiling: invalid target release: 1.8.0_73 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Below is the pom.xml which I am using as of now.
<?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>com.amazon</groupId>
<artifactId>amazon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyApplication</name>
<description>Demo project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8.0_73</java.version>
<start-class>com.amazon.service.MyApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-jasper -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
According to your logs:
Fatal error compiling: invalid target release: 1.8.0_73
You might be using an inferior JDK version (1.7 for example) to compile your project to a higher target version (1.8.0_73 in your case).
Try installing JDK 1.8 and make your JAVA_HOME environment variable point to it.
Generally you should make sure the source JDK and target JDK are matching between your pom.xml file and your JAVA_HOME environment variable.
You can try maven compiler plugin
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Remove the duplicate dependency added
<artifactId>spring-boot-starter-test</artifactId>
And
Try pointing to JDK 1.8 in project build path and make your JAVA_HOME environment to this
In general the minor release number (for java) is not configured in pom.xml. Only major release number will be require.
Try to change 1.8.0_73 to 1.8.
To understand the java version system please visit this link.
Looking in your maven output, it is clear that you have a duplicate dependency declaration. Moreover, it is clear that the duplicate dependency is the org.springframework.boot:spring-boot-starter-test.
What is the process of solving the issue and removing this WARNING:
Look VERY carefully your pom.xml. You probably have declared the dependency twice.
An other cause of this warning might be that a dependency is declared twice, but with different versions. The solution, again, is to delete the dependency for one of them.
Command mvn dependency:tree -Dverbose might be useful.
Finally, after writing the above process, I looked in the pom.xml file you posted in your question and found that you have declared the following dependency twice (line:54 and line:65).
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
As far as I am concerned, this library is used for testing purposes only. If this is true, depending on your requirements, you should keep only the dependency in line 54 and the warning will be removed.