I have a class in an application (it is a Spring Boot project), for example:
package com.exemple.spring.springboot.model;
public class Employee {
...
}
And in the pom.xml I have this:
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.exemple.spring</groupId>
<artifactId>spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
...
Now I want to use this class Employee in another application like this:
package com.exe.spring.controller;
import org.springframework.stereotype.Controller;
import com.exemple.spring.springboot.model.Employee;
@Controller
public class EmployeeController {
public Employee getAnEmployee() {
...
}
}
I've build the JAR with mvn clean install
for the first app and I've added it in the pom.xml of the second app like this:
<?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.exe.spring</groupId>
<artifactId>rest-client</artifactId>
<version>1.0-SNAPSHOT</version>
<name>rest-client</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.exemple.spring</groupId>
<artifactId>spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
And the problem is that I cannot import the Employee class in the EmployeeController class. I've imported it manually like this import com.exemple.spring.springboot.model.Employee
;, but Intellij show me an error: Cannot resolve symbol 'springboot'. I see that the dependency is presented in the local repository. It is very weird because Eclipse doens't see anything to import for Employee, and Intellij see the class but when I try to click on "Import class" it doesn't import anything. What can I do to import it correctly? Thank you!