Adding a new dependency to pom does not work in eclipse - java

I am having an issue while adding a new dependency to my pom.xml. I have an existing Maven project in eclipse. I added a new dependency to my pom.xml as follows:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.1</version>
</dependency>
After that I right clicked on the project --> Maven -->Update project. However, there is a compilation error for the class for the following line:
private JavaMailSender mailSender;
The JavaMailSender is not found. Any idea what might be the issue?

You could try to do right click on the project > Maven > Update project and check "Force update of Snapshots/Releases"
Or you can force to download the dependencies from terminal with the following command:
mvn clean install -U

You need to add the dependency, then compile it.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.0.5.RELEASE</version>
</dependency>

Related

How to find out what kind of dependencies I can use from local repository in maven?

So I ran mvn clean install in first project, I find it in my local maven repository. But how am I supposed to know what to type in project two pom.xml to use the jar I just installed to my maven repository?
I need the following but with my installed project values:
<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.4</version>
</dependency>
How to find out how to pull my first project dependency into my second project?
In your pom.xml of the second project enter this inside dependencies tag . so it should be something like this,
<dependencies>
<dependency>
<groupId>group id of first Project</groupId>
<artifactId>Artifact id of first project</artifactId>
<version>version of the first project</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.4</version>
</dependency>
<dependencies>
you can find all those information from pom.xml of the first project

Unable to get Groovy version from GroovySystem, trying InvokerHelper

we are using groovy on a java + maven project and getting below error during the build:
INFO] Unable to get Groovy version from GroovySystem, trying InvokerHelper.
[ERROR] Your Groovy version (1.1-rc-1) doesn't support compilation. The minimum version of Groovy required is 1.5.0. Skipping compiling.
My pom.xml have this dependency:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.12</version>
<scope>compile</scope>
</dependency>
Any idea?
try this, it works for me:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.5.7</version>
<type>pom</type>
</dependency>
I faced the same problem. in my case, groovy-all.jar was corrupted. if it is so you can do followings
remove
$USER_FOLDER\.m2\repository\org\codehaus\groovy\groovy-all
then
Right click on the project click Maven->Update Project
as shown below image.

Maven does not download dependency

I just added directjngine to my maven project dependencie list the following way:
<dependency>
<groupId>com.softwarementors.extjs</groupId>
<artifactId>directjngine</artifactId>
<version>2.2</version>
</dependency>
However after I do a maven update on the project, it says that this dependency is still missing. Am I doing something wrong?

Running an app built with Play in IntteliJ gives error on Maven dependency: Package not found

I'am using IntelliJ with Maven and Play framework.
Made a small app. Using maven to include a dependency. Compiles fine - but dependency gives an error when running: "Error: Package not found"
So, I suspect that the dependency jar must be copied to another folder in order to work? But how and where? Did expect maven to do this automatically? (I have tried to run a maven install)
POM.XML
<dependencies>
<dependency>
<groupId>org.ektorp</groupId>
<artifactId>org.ektorp</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
Error message in IntelliJ :

maven dependecies can't be imported

I have set-up a mave project in Eclipse, I added the project dependencies to the pom.xml which was created by eclipse automatically.
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId> org.springframework.core </artifactId>
<version>3.0.6.RELEASE </version>
</dependency>
</dependencies>
Now when I import the Jdbc template in one of the classes, I get the import can't be resolved error
import org.springframework.jdbc.core.JdbcTemplate;
Are dependencies added during compilation time, or execution time only? if they are only available at execution time, then how can I compile the code?
One way to verify if maven dependencies are added to your project or not in eclipse is under the project ->libraries->Maven Dependencies, all the dependency you have added in your pom.xml should be present
In your case spring-jdbc{version}.jar should there else try to update the project, while updating the project by default all the dependencies would be downloaded to your home directory/.m2/repository. If you find your dependencies are not present check your proxy settings. http://maven.apache.org/guides/mini/guide-proxies.html
The simple problem you have is that the class org.springframework.jdbc.core.JdbcTemplate is contained in the following artifact:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
but not in the spring-core nor as transitive dep. Apart from that you should first check to build the project on command line with Maven and afterward import it into Eclipse.

Categories