add cxf jar file in maven project? - java

I need to add cxf-core, cxf-frontend ext. file in the project. I am trying to add these using maven dependency in pom.xml but it didn't work and version number is getting be red when it is added.
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
<version>2.6.2</version>
</dependency>
org.apache.cxf:cxf-rt-core:2.6.2 not found.
I also tried to add using external .jar libraries. The IDE is Intellij IDEA.

2.6.2 worked for me, I used Eclipse to create a new maven project and pasted in your dependency. It worked, fetched the required jars and give me this dependency hierarchy.

Related

How to check that where in the Spring boot project (Intellij Idea), particular maven dependency is used?

In the pom.xml file there are many dependencies are added. I want to check one particular dependency is used where in the whole project. I am using Intellij Idea for Spring Boot project. Project is too big to check each file manually.
I want to check where the below dependency is used in the project?
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
Two ways :
First :
CTRL+shift+F and search for "com.google.guava". This will give you all the files where classes from this package has been imported.
Second :
Remove the dependency from pom.xml. And reload your pom changes.
This will remove your library from classpath. As soon as this happens, your IDE will start showing red lines under all the classes where your dependency has been used as it'll not find classes from your library mentioned in imports.

How do I resolve dependency conflict for a Java file in IntelliJ IDEA?

I have tried to search web for the problem I am facing but maybe I am not asking google the right question so here I am.
I am using IntelliJ IDEA for my multi-module project. For one of my modules, one of the class file is using a static import -
import static javax.ws.rs.core.Response.Status.Family.familyOf;
Being a big project, there are a lot of dependencies downloaded from internal repo but for some reason IntelliJ refuses to use the dependency "javax.ws.rs-api-2.0" instead it is using "jersey-core-1.8". Because of this it is throwing a compilation error saying Cannot find symbol "familyof".
I looked into Response.java from both the dependencies and found that jersey dependency does not have familyof method while javax.ws.rs-api-2.0 has it but IntelliJ doesnt use this dependency. How do I fix this problem. Most of the developers in my team are using Eclipse and they do not have this problem. I am trying to get used to IntelliJ IDE but cant seem to figure a way out of this. Any help in this regard is much appreciated.
PS - This issue does not occur in Eclipse IDE.
I could resolve this issue by following the below mentioned steps -
Goto "Open Module Settings" Command+Down arrow key
Select Dependencies tab
Search for the above two dependencies in the list
Move "javax.ws.rs-api-2.0" dependency up to ensure this dependency is above "jersey-core-1.8" dependency.
I don't think this is a permanent solution but it seemed to work. if someone with in-depth knowledge of Java/Mave/IntelliJ has an answer to this question that would be great!
You may be able to get the right result every time with Maven by shuffling around the dependencies in the pom.xml, and make sure the dependency you want to take precedence is declared first in the list of dependencies. yes, the order in which the dependencies are declared in pom.xml matters !
Then, if all of you are using the same Maven version, you should have a consistent result.
How does Maven choose between two versions of a same dependency?
As explained here, Maven chooses the first met dependency that's why it works when you change the order of the dependency in the pom.
How to find Maven dependencies conflicts?
In a terminal, in the pom folder :
mvn dependency:tree -Dverbose | grep "conflict"
will give you all the dependencies in conflict in your project.
With Eclipse IDE, click on the pom and on the Dependency hierarchy tab. Then, fill the Filter field with a dependency. On the left side, you will see the conflicts (like with mvn dependendy:tree, with filtered results) and on the right side, the dependencies chosen.
With IntelliJ, the documentation of IntelliJ can help you. There is a diagram view to find the conflicts.
How to resolve Maven dependencies conflicts?
Add dependencyManagement tag in the pom to tell Maven which dependency you want
Example :
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<dependencies>
</dependencyManagement>
Change the order of the dependency in the pom
Add an exclusion of the dependency
Example :
<dependency>
<groupId>com.my.groupid</groupId>
<artifactId>my-artifact-id</artifactId>
<version>1.2.2</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
</exclusions>
</dependency>
Why is there a difference between IntelliJ and Eclipse?
You can add a dependency to a module without adding it to the pom as explained in the documentation of IntelliJ. It's probably possible with other IDE.
IntelliJ IDEA lets you add a Maven dependency to your project. We recommend that you specify the dependency inside your POM. Dependencies that you set up manually inside IntelliJ IDEA module settings will be discarded on the next Maven project import.
The Maven plugin in Eclipse (M2Eclipse) may load dependencies differently compared to mvn
Please, read the documentation of IntelliJ to configure the project dependencies easily.

How to build a project on github with pom.xml

This might be a naive question, so pardon me but I am new to maven.
I want to build a jar of project present on github. The project has a pom.xml file and additionally mentions in
Installation Note:
Releases are distributed on Maven central:
<dependency>
<groupId>some_grp_id</groupId>
<artifactId>all</artifactId>
<version>1.1.2</version>
<type>pom</type>
</dependency>
Am I suppose to add above in the existing pom.xml file ??
I an cloning the project on my desktop and then executing "mvn package".
If you want to simply use the library then you only have to add the above dependency to your pom.xml. Maven is doing all the rest for you (downloading the .jar-file).
If you really want to use the source code you have to do a
mvn install
on the checked out code. And also have to include the dependency in your own pom.xml.

Android Support Library v7 + Maven + Eclipse: apklib dependency not found in workspace

I'm trying to configure the library v7 support in my project so that it uses ActionBarActivity, thus keeping compliant with some of the Android 2.X versions.
First, follow the documentation from Google and imported the project android-support-v7-appcompat as a library in accordance with Section Adding libraries with resources on Support Library Setup. But this way my Maven Build failed because it could not find the dependence of the library in question.
Now, I decided to seek a cleaner solution, keeping my dependences managed by Maven. To do this follow the instructions of the answer, but using version 19.0.1. This made my Maven Build it were executed successfully, but my project is not compiling in my workspace, the following error occurs on first line of my POM:
dependency=[com.android.support:appcompat-v7:apklib:19.0.1:compile]not found in workspace
My dependencies are as follows:
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>${com.android.support-version}</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>${com.android.support-version}</version>
<type>jar</type>
</dependency>
The project in question is on GitHub, if they want to view it: https://github.com/veniltonjr/msplearning
Thank you in advance!
First, there is no apklib for com.android.support:appcompat-v7. It only ships as an aar.
Second, that library is not available in maven-central, it ships with the Android SDK.
You need to manually deploy it to your local maven repository.
Though you can use maven-sdk-deployer to construct and deploy the apk to your local folder. But you github project is failing due to missing internal dependencies.
com.msplearning.android-support-v4:jar:19.1.0, com.msplearning:android-support-v7-appcompat:jar:19.1.0

Is there a maven repository for flash-selenium.jar?

I recently moved to maven project and since then I found adding dependencies very difficult. Before that I just needed to download the jar and add to library folder .
Now I am searching flash-selenium.jar dependency but I failed to find any. So I added it manually in my C:.m2\repository\org\seleniumhq\selenium\flash-selenium folder but still it is giving error. So how can I use this jar in my maven project?Its a request to people those have 1500 points here , could you please create a label for selenium flash related problems. Thanks
There's no flash-selenium dependency in maven central, but there are other artifacts like:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0rc2</version>
</dependency>
the complete list:
http://search.maven.org/#search|ga|1|selenium
Maybe some of this fits what you need.

Categories