I have created a new maven project by choosing org.apache.maven.archtypes maven.archtype.webapp.
I perform the below commands:
right click pom > maven clean
right click pom > maven install.
check maven user setting file
right click on project > maven update.
but maven dependency library is not added into libraries folder although a build success message has been output.
[INFO] Scanning for projects...
<p>
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO] BUILD SUCCESS
[INFO] Total time: 2.248 s
[INFO] Finished at: 2018-06-07T09:40:57+03:00
[INFO] Final Memory: 8M/20M
Here's my pom file, e.g dependency mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-
<?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.0http://maven.apache. rg/xsd/maven-4.0.0.xsd">
<groupId>test</groupId>
<artifactId>maven.test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>maven.test Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<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>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310 -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Here's my library screenshot without maven dependency
As Amer mentioned , do a maven update for your project, if it doest work the try with different network(either use mobile phone network or home network) to update project then do a eclipse clean(not maven clean) for that project then do a maven install. sometimes network block the jar file to download
right click on the project -> maven -> update project
I saw screen shot you attached but there is not any folder called "Maven Dependencies". So please try one option it may solve your problem...right click on project -> configure -> convert to maven.
go to the source folder of the project using cmd and
run maven command:
mvn clean install (this command won't work unless you specified path to maven/bin folder in path of system variables)
be sure you're not beyond the proxy, if you are, then you should configure maven to work with it. Link to how to configure a proxy in maven
Related
I first ran maven locally using:
mvn release:prepare -DreleaseVersion=1.1.2 -DautoVersionSubmodules=true -Dresume=false -Dtag=1.1.2 -DdevelopmentVersion=1.1.2-SNAPSHOT
but some third party dependencies like :
<properties>
<core.version>1.0.0-SNAPSHOT</core.version>
</properties>
<dependency>
<groupId>com.demo</groupId>
<artifactId>core</artifactId>
<version>${core.version}</version>
</dependency>
I want to replace 1.0.0-SNAPSHOT with 1.0.0,What should I do now?
https://github.com/bvanalderweireldt/concurrent-unique-queue
I have tried to set up a Maven dependency within IntelliJ, but I am not sure how the contents of this repository should be built and imported into a Java project. Could someone with more experience please advise on how this is done?
Kind regards,
L
If you want to use this project in another project, you will create a dependency to this using the dependency entry mentioned on the github readme:
<dependency>
<groupId>com.hybhub</groupId>
<artifactId>concurrent-util</artifactId>
<version>0.1</version>
</dependency>
For this, you need the artifact in your local maven repository*. For this, you need to build this project or use a reference from Maven Central (Thanks #Mark Rotteveel )
Clone the project locally, you need to build it in one of the following ways
Build it from the command line: Navigate to the project's location in your shell (bash or cmd) and run mvn install
This will build the project and add the artifact (jar) to the local .m2 repository.
Import to Intellij Idea (File -> New -> From Existing Sources). Once imported, build this project from the "Maven Projects" view.
Once you have done this, you can use this in other projects using the <dependency> entries
*For production ready apps, you may want to have a common maven repository for team your like Nexus or Artifactory and use that to maintain artifacts. You would also have a build system like Jenkins.
In the link you gave it had the dependency Maven entry for that library.
<dependency>
<groupId>com.hybhub</groupId>
<artifactId>concurrent-util</artifactId>
<version>0.1</version>
</dependency>
That entry would need to be nested into you <dependencies> tag. Like the example below.
<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.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.hybhub</groupId>
<artifactId>concurrent-util</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I'm not getting any red lines, but IntelliJ can't find my Maven dependencies when I run the (Play) app. Tried invalidate cache/restart. Tried running mvn clean install.
compiler error message
(compile:compileIncremental) Compilation failed
[info] Compiling 8 Scala sources and 5 Java sources to /Users/****/IdeaProjects/GeoMood/target/scala-2.11/classes...
[error] /Users/****/IdeaProjects/GeoMood/app/views/show_tweets.scala.html:1: not found: value twitter4j
[error] #import twitter4j.Status
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>groupId</groupId>
<artifactId>geomood</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.8.0</version>
<classifier>models</classifier>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[4.0,)</version>
</dependency>
</dependencies>
</project>
Does anyone have any ideas why IntelliJ isn't picking this up? The maven build runs fine, and the dependencies are listed under external libraries.
I usually have to do the following to make IntelliJ aware of changes to my dependencies in the pom.xml:
Right click the root folder of the project in IntelliJ's project view
Go the the Maven menu item, and open the Maven submenu
Click Reimport
It sounds like you've hit bug IDEA-148573:
when a Maven dependency uses a classifier, IDEA ignores the classifier when building its classpath and tries to use the non-classified artifact for that dependency
If I wanted to use just the normal git via the command line and not the one in IntelliJ, what do I need to include in the version control so when I download it, I can get the Maven libraries without manually installing them?
Edit: There is no pom.xml file when the libraries are added to an IntelliJ project, so I was wondering what I need to include so Maven inside IntelliJ can download the libraries.
what do I need to include in the version control so when I download it, I can get the Maven libraries without manually installing them?
The pom.xml file does this:
Some of the configuration that can be specified in the POM are the project dependencies, the plugins or goals that can be executed, the build profiles, and so on. Other information such as the project version, description, developers, mailing lists and such can also be specified.
Running mvn install will cause Maven to download your dependencies.
Intellij will automatically understand the changes in the pom files and update libraries of course you should have pom.xml file.
If its a maven based project, you definitely need a pom.xml file like below
<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.test</groupId>
<artifactId>testing</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>testing</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>
</dependencies>
</project>
Once you have a pom.xml file, you can define dependencies like the JUnit dependency defined above with the version you need and maven will automatically take care of downloading the dependency for the project. Once you add any new dependency to the pom.xml, you can run "mvn clean install" from the directory where you have the pom.xml file so that it installs the new dependency.
Hope this helps.
I have installed maven and I created a project using this command:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
The result is there are 2 folder and 1 file created in my-app folder: src, target, and pom.xml.
Then I modify the pom.xml in order to get the all of required apache POI jars.
<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.mycompany.my-app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- This is what I added -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>
</dependencies>
</project>
Then I run:
mvn package
but no jars downloaded into the project folder although I got message "BUILD SUCCESS".
What you've done is correct. However, the poi jars won't download to your project folder but to your local Maven repository. This is exactly what Maven is supposed to do so that you don't have to manage many libraries/jars yourself and get all in a mess. If you do a search of your local Maven repository, you should find it there.
I also suggest you read up on how Maven uses external dependencies, this is all explained here:
http://maven.apache.org/guides/getting-started/index.html#How_do_I_use_external_dependencies
If you want to package up all of your dependent jars in to one big jar look here:
How can I create an executable JAR with dependencies using Maven?
Your project has a jar packaging type. Java not support nested jar and then maven package doesn't put any jar in your project . To do this you have to use Maven Assembly Plugin or use Spring-boot to make your uber jar