Maven, package does not exist
From your sample, we cannot see any artifact containing the package com.mycompany.common.objects
you are using.
You are adding dependency com.mycompany.Common:common as a POM (and you are declaring the packaging of com.mycompany.Common:common as POM too). If it is actually a JAR artifact that contains the package you need to use, then remove the packaging
from the POM and dependency (which means, using default which is JAR).
Maven compile: package does not exist
You have to add the following dependency to your build:
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-rio-api</artifactId>
<version>2.7.2</version>
</dependency>
Furthermore i would suggest to take a deep look into the documentation about how to use the lib.
Maven: 'Package does not exist' (and other errors)
Looks like your issue appears due to fact that you trying to access from your:
src/main/java
Test sources - which are located:
src/test/java
Here is the exact snippet of the log you posted:
/Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[15,43] package com.company.automation.ecom.pages does not exist
It will work from another side: if you will use your sources (src/main/java
) from test scope (src/test/java
).
Maven has his own lifecycle.
It has a strict consequence:
compile
- compile the source code of the projecttest
- test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
And during compile
you can compile only your sources. However, it depends on your tests (pages package), which can't be compiled at this moment, because it will compile only at test
phase.
Thus compilation fails.
For solving try to change your project structure, a little bit:
src/main/java
{package com.company.automation.ecom}
CreditCard.java
HelperMethods.java
{package com.company.automation.ecom.pages}
Header.java
SignIn.Java
(etc...)
src/test/java
{package com.company.automation.ecom.tests}
HeaderTests.java
And your tests should use sources (core & pages) without any problem.
Maven build failure: package does not exist
I try to answer the question as far as I understand it:
If you have two projects A and B and A depends on B, then you have to have to build B first. If you e.g. use mvn clean install
, then B.jar will be put into your local repository. After that, you can build A against it (if you choose the correct version in the pom).
Maven compilation error: package does not exist
Since I was running out of options, I followed what was suggested by @user944849 and updated Maven to version 3.3.9 and my JDK to 1.8.0_60, but kept source and target on the compiler configuration of the POM pointing to 1.6.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
After that, module 3 began to compile, but modules 4 and 5 broke due to dependencies on some JRockit libs. To fix that, I ended up updating the deprecated code and the project finally fully compiled.
So I believe there was a problem on the Maven version I was using. Somehow it seems to get lost when 2 projects depended on the same lib and one of them depended on the other. I haven't tested other versions, but the 3.3.9 works fine for these cases.
Maven build fails: package does not exist
As the documentation explains, a spring boot project isn't suitable as a dependency for the projects, as the class files are placed somewhere where they can't be seen by the other project, in BOOT-INF/classes: https://docs.spring.io/spring-boot/docs/1.5.x/maven-plugin/examples/repackage-classifier.html
Maven java: package does not exist
As you guessed, the problem is that you didn't include JDA as a dependency (library).
In order to do this, add this to the pom.xml
:
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_222</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
See the README of JDA for details.
The first section (<dependencies>
) declares your dependencies (libraries).
Here, you add a dependency with the group id net.dv8tion
and artifact id JDA
with version 4.2.0_222
(the latest version at the time of writing this (may 2nd, 2020).
The second section (<repositories>
) defines where to look for. JDA is not in the maven central (the default) repository but in the jcenter repository so you need to add the jcenter repository to your pom.xml
.
If you package it to a JAR, dependencies will not be included. In order to do this, you can use the maven-assembly-plugin
, for example.
You can add the plugin to the pom.xml
wth the following code in the <plugins>
secion:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>yourPackage.yourClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Integrated in your pom.xml
, it could look 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>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<groupId>com.bananaaction</groupId>
<artifactId>IdeaProjects</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_222</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>yourPackage.yourClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Don't forget to change the main class, however.
Related Topics
Get Timezone of Area With Country Code in Java
How to Check If the File Is Image
How to Change the Colors of Text and Background for Cmd in Java
How to Extract Ip Address in Spring MVC Controller Get Call
Use a Binary Search on an Int Array Sorted in Descending Order
Can a @Manytoone JPA Relation Be Null
Validate an Enum With Springframework Validation Errors
Getting Data from Incoming Json in a Java Servlet
Broadcast Receiver Is Not Working When Application Is Removed from Background
Classcastexception: Java.Math.Biginteger Cannot Be Cast to Java.Lang.Long on Connect to MySQL
Automatically Size Jpanel Inside Jframe
Testing Two Json Objects for Equality Ignoring Child Order in Java
Android Tv Recyclerview Set Next Focus of Its Item
Converting Number Representing a Date in Excel to a Java Date Object