I am building android application in which I have imported one of the maven library from this link https://github.com/devnied/EMV-NFC-Paycard-Enrollment.My project name is Nfcs and I have no errors in the project and I have added all of the dependencies in my project successfully but when I run the project error window opens saying "Your projects contains error please fix them before running".Please help me find out the error...
pom.xml of the library project.
<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>
<artifactId>library</artifactId>
<packaging>jar</packaging>
<name>EMV paycard library</name>
<parent>
<groupId>com.github.devnied.emvnfccard</groupId>
<artifactId>parent</artifactId>
<version>1.1.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.github.devnied</groupId>
<artifactId>bit-lib4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<!-- Unit test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
You error message says:
... Run Maven->Update Project or Use Quick Fix.
As you see the error is on your Maven Project, you should follow the hint Eclipse is giving you! And Right Click on your Maven Project > Maven > Update Project.
Usually, Eclipse hints are quite usefull.
Read this post to understand what this function is used for. You have to keep in mind that Maven is not the 'native' build manager in Eclipse and therefore needs a little adaptation and additional operations in order for it to work properly.
Related
I know what you'll think in the first place: "You should name your test classes with 'Test' in it etc."
But the problem is: it's already the case. I did scroll every possible SO post and didn't find anything, so no, unfortunately, this is not a duplicate.
I even have a test class named TestPleaseWillYouRunMyTest and a test method called testPleaseTest().
When I run a "mvn test", the "target/test-classes" folder is well populated, so I really don't understand why my tests aren't run...
Just in case it would help understand the problem, here is 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>org.example</groupId>
<artifactId>SeleniumTests</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>10</source>
<target>10</target>
</configuration>
</plugin>
</plugins>
<testSourceDirectory> src/test/java </testSourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-alpha-3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
</dependencies>
</project>
Why you added testng, junit 4 and 5? first decide which testing framework you want to use
just to add my 5 cent to what khmarbaise said:
if your tests sit in standard directory you don't need to add testSourceDirectory at all, this tag is for non standard places.
Also you entry there is incorrect: src/test/java - this is definitely not the place where your test are.
mvn test
Only compiles the test classes but does not run the tests. In order to let the tests run use:
mvn verify
I want to Implement Microsoft Graph API for sending an email.
For that, I have referred the code from https://github.com/microsoftgraph/console-java-connect-sample.
But, The code present here is in Gradle format. I need it in Maven format.
What I Want to do is :
Get The access token from GraphAPI
Using This Access token Call the Send Mail API of GraphAPI
I have perfrom above two functionality using postman.
same I want to implement using Java & Maven
Please let me know if any sample available for this functionality using Maven
Maven and Gradle are just build tools. You can use that sample, just need to create a pom.xml file with dependencies used in build.gradle file. I have done that for you.
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>test2</groupId>
<artifactId>test2</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
<version>4.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.scribejava</groupId>
<artifactId>scribejava-apis</artifactId>
<version>6.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.gilecode.yagson</groupId>
<artifactId>j9-reflection-utils</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Download that sample and delete all the files except src folder, put the pom.xml together with src folder. A maven project has done.
Here is my pom.xml file, when i am importing the project, its is showing error on the top line in pom.xml file as "failure to transfer xstream because its cached in the local directory, resolution will not be reattempted until the update interval of central has elapsed or updates are forced"
I am totally new to this please help me out.
I was learning through a tutorial Spring with JPA and Hibernate, but i am stuck with this please help me out, and thanks in advance
<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.pluralsight</groupId>
<artifactId>FitnessTracker</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>FitnessTracker 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.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.3.Final</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.8</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<finalName>FitnessTracker</finalName>
</build>
</project>
Use -U parameter while building your project.
mvn clean install -U
If it does not work delete xstream's folder from your local maven repo and do
mvn clean install -U
In keeping with the m2e bug/issue, I followed the solution mentioned #SL4j m2e fails to load in Eclipse IDE.
My Pom.xml looks like this (for my JUnit and Selenium dependencies):
<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>TestJUnit</groupId>
<artifactId>TestJUnit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.41.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.41.0</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
However when I do a mvn compile I get the following kind of error:
[ERROR] /path:/to/file/<foldername>/<JUnitClassName>.java:[9,17] package org.junit does
not exist
I am new to maven, is there something that I am doing wrong here.
In your <dependencies> list, you specified JUnit with the scope of test, which means that it is only included in the jar when you do mvn test, but not included in mvn compile. If you want JUnit to be included in your final jar, change the <scope>test</scope> to <scope>compile</scope> or you can jsut remove the tine, they both do the same.
TL;DR use mvn test to test your application; or change <scope>test</scope> to <scope>compile</scope> in the junit dependeny decleration.
I did the same thing when I first started using maven, almost everyone does :P
My pom.xml looks as follows:
<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>be.ugent.sop.p404</groupId>
<artifactId>P404</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>P404EJB</artifactId>
<name>P404EJB</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<ejbVersion>3.1</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.29</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.5.2-M1</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.databene</groupId>
<artifactId>contiperf</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.databene</groupId>
<artifactId>contiperf</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee-deployment_1.1_spec</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<packaging>ejb</packaging>
As one of the examples of the problems I am receiving:
Description Resource Path Location Type
Project 'P404EJB' is missing required library: '/home/zeesteen/.m2/repository/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar' P404EJB Build path Build Path Problem
I assumed that after using the following command:
mvn clean install eclipse:eclipse
Maven was supposed to fetch libraries that are in the pom and not present on my machine yet? (The folders, for example "com" don't exist in the .m2/repository folder)
I have tried multiple solutions myself such as
- Removing the Maven nature, clean installing again, converting to a maven project
- Doing variations on the clean command
- Right clicking on the project and doing Maven > update Project
- Cleaning the project through eclipse
I got 124 Java Build Path Problems like the one mentioned above.
I found the mistake..
Maven didn't give errors because there was nothing wrong with my maven repo apparently. Eclipse had changed the location of my settings.xml maven file to a "nonexistent" location.. Resulting in all the problems. I manually changed it back and all problems are solved.
In Eclipse I did:
Window > Preferences > Maven > User Settings: Field User Settings was wrong
(eclipse changed it..) put it back to where I first made the settings, applied, cleaned the project and everything was fixed!
Please make sure that you have added Maven Dependencies under Libraries in Java Build Path.
Note : You can check the properties by Right-clicking the project and click Properties. If it is NOT added, you can click Add Library and select Maven Managed dependencies and finish