Issue
I am learning Spring in maven environment. I am using netbeans.
pom.xml
<dependencies>
<?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>com.davidsalter.cookbook</groupId>
<artifactId>springMavenTest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.4.RELEASE</version>
</dependency>
</dependencies>
</project>
And spring.context-4.3.4.RELEASE.jar appears under Dependencies. Under Java Dependencies i only have JDK1.8.
When i have to configure my beans in a java class using @Configuration and @Bean annotations i can't import org.springframework.
Solution
It seems that you just create a maven project in NetBeans. The maven dependencies you declared in pom.xml
will be downloaded and listed in the Dependencies
folder.
Right click on Dependencies
folder and click on Download Declared Dependencies
to reload the dependency. If still failed, you may need to check your maven proxy in setting.xml
.
Answered By - Dave Pateral
Answer Checked By - Marilyn (JavaFixing Volunteer)