I want to run tests using java & robotframework using maven.
I have inserted the dependencies of robotframework and the related plugin in the pom.xml file.
I also tried inserting the dependency on com.sun for the tools.jar file, but running doesn't work.
As for the run setup I inserted a custom maven run with the base directory of the project and as goals I inserted robotframework:run.
I also tried to create an eclipse link by putting the correct path for tools.jar but it doesn't work the same.
This is the error that appears to me:
Could not find artifact com.sun:tools:jar:1.7 at specified path C:\Program Files\Java\jre1.8.0_191/../lib/tools.jar
<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>AppQuality</groupId>
<artifactId>EVD_Robot_01</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>EVD_Robot_01</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.robotframework</groupId>
<artifactId>robotframework-maven-plugin</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.robotframework</groupId>
<artifactId>robotframework</artifactId>
<version>2.8.7</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Related
I have added some Maven dependencies with SystemPath tag:
<dependency>
<groupId>OFRestCallBroker</groupId>
<artifactId>OFRestCallBroker</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}\src\lib\OFRestCallBroker.jar</systemPath>
</dependency>
Ok, so following one of the stackoverflow thread
Add external library .jar to Spring boot .jar internal /lib
I updated to this
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
But when I generate the .war file, these dependencies are not included in the WEB-INF folder and a separate lib-provided folder is generated but still I get this error java.lang.NoClassDefFoundError.
And due to this, when I deploy these files on the Tomcat server. I get java.lang.NoClassDefFoundError error.
My Spring Boot version <version>2.2.11.RELEASE</version>
Please help out with the correct approach and preferred some example
As mentioned in comments System scope is deprecated. best approach is use an artifact manager like jFrog artifactory or install your preferred dependency in your local repository {home-dir}\.m2.
To do this you can use Maven install command:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
suppose we have a my.jar file located in project root directory src\lib\my.jar
Then add it as regular dependency to dependencies of my project:
<dependency>
<groupId>a.b</groupId>
<artifactId>my</artifactId>
<version>9.0.0</version>
</dependency>
But if you want an automated way to install your jars that are located in src/lib into your local repository can utilize Maven install plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-external-non-maven-jar</id>
<phase>clean</phase>
<configuration>
<repositoryLayout>default</repositoryLayout>
<groupId>a.b</groupId>
<artifactId>my</artifactId>
<version>9.0.0</version>
<file>${basedir}/src/lib/my.jar</file>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
By executing mvn clean command, my.jar file will be installed in local repository and then by mvn package or mvn install command execution, your war file will be created.
final 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 https://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.4.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>a.b</groupId>
<artifactId>my</artifactId>
<version>9.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-external-non-maven-jar</id>
<phase>clean</phase>
<configuration>
<repositoryLayout>default</repositoryLayout>
<groupId>a.b</groupId>
<artifactId>my</artifactId>
<version>9.0.0</version>
<file>${basedir}/src/lib/my.jar</file>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
If you have a company Nexus/Artifactory, put the dependency there.
Otherwise install it into the local repository with mvn install:install-file.
Then you can reference it without using system scope.
enter image description hereenter image description hereI have used maven plugin in eclipse so I dont see any setting.xml even I tried by adding manually setting.xml.
What I am missing please correct me with In details step.
My pom is
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>demo</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.project</groupId>
<artifactId>SOA_API_Automation</artifactId>
<scope>system</scope>
<version>0.0.1-SNAPSHOT</version>
<systemPath>{jar/path}</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
If you are referring to the settings.xml which is user-specific configuration for Maven, that is not present inside the POM. It's present in ~/.m2/settings.xml. For more details refer the maven doc
I have a spring boot application which I am trying to run from command line on my Mac but I get following error:
Error: Could not find or load main class MyProject.jar
Here is my 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.myproject.abc</groupId>
<artifactId>MyProject</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
</parent>
<properties>
<start-class>com.myproject.abc.MyMain</start-class>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>target/MyProject-1.0.0.lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
<archive>
<manifest>
<mainClass>com.myproject.abc.MyMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have referred various posts online and as visible from above pom.xml, have tried adding <start-class>, spring-boot-maven-plugin, but nothing worked.
On further searching found following link Maven error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher, I removed M2_HOME from .bash_profile which looked as below
export M2_HOME=/Users/myuser/Downloads/apache-maven-3.5.4
export PATH=$PATH:$M2_HOME/bin
Then I installed maven using brew -> deleted the .m2 folder -> ran mvn clean install-> run java MyProject.jar
Still facing same issue. Any ideas?
My maven project plugs are in red and they wont download. how can this be resolved? here is an image of the maven projects fro intellij:
and here is my pom.xml file contents:
<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.example.ema</groupId>
<artifactId>jerseyexample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>jerseyexample Maven Webapp</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.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.10.1</version>
</dependency>
</dependencies>
<build>
<finalName>jerseyexample</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>TomcatServer</server>
<path>/newjersey</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
i put the mouse over the first maven directory in the image called 'jerseyexample Maven Webapp' and it showed the following error, hope this helps:
and here is how i added the jersey dependencies... i simply downloaded the jar files and added them to the app module:
the issue was with my settings.xml file that maven uses to build the project. I had a mirror defined in there that used a proxy and it was blocking the download
i have a project in eclipse where i try to run a selenium junit test.
I converted the project to Maven
When i run this java -jar My-Test-0.0.1-SNAPSHOT.jar
It says:
no main manifest attribute, in My-Test-0.0.1-SNAPSHOT.jar
What is wrong with me pom file?
The 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.blogspot.test</groupId>
<artifactId>My-Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>My-Test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.44.0</version>
</dependency>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>all</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</dependencies>
</project>
Is your project a web project?? Because as I know, Selenium only works with web projects. And there you have your project packaged as a jar (not as a war)