c'est moi :
I am trying to develop a multi-module maven application with Spring Boot but I have a problem with the communication between modules
github repo: https://github.com/dali05/SpringBootMultipleMavenModules
the application is made up of 4 modules
flad-access contains my controller
flad-dao contains my Repository and my Entity
flad-framework
flad-service contains my service and their implementation
the parent module => flad-manager (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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.lma</groupId>
<artifactId>flad-manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>flad-manager</name>
<description>flad-manager</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<flad-version>1.2.7-Alpha</flad-version>
<java.version>1.8</java.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- flad-framework -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-framework</artifactId>
<version>${flad-version}</version>
</dependency>
<!-- flad-dao -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-dao</artifactId>
<version>${flad-version}</version>
</dependency>
<!-- flad-service -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-service</artifactId>
<version>${flad-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<modules>
<module>flad-framework</module>
<module>flad-dao</module>
<module>flad-service</module>
<module>flad-access</module>
</modules>
</project>
flad-access (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>
<parent>
<groupId>com.lma</groupId>
<artifactId>flad-manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>flad-access</artifactId>
<packaging>jar</packaging>
<dependencies>
<!-- flad-framework -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-framework</artifactId>
</dependency>
<!-- flad-service -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-service</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
</dependencies>
</project>
flad-dao (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">`
<parent>
<groupId>com.lma</groupId>
<artifactId>flad-manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>flad-dao</artifactId>
<dependencies>
<!-- flad-framework -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-framework</artifactId>
</dependency>
</dependencies>
</project>
flad-framework (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">
<parent>
<groupId>com.lma</groupId>
<artifactId>flad-manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>flad-framework</artifactId>
</project>
flad-service (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">
<parent>
<groupId>com.lma</groupId>
<artifactId>flad-manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>flad-service</artifactId>
<dependencies>
<!-- flad-framework -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-framework</artifactId>
</dependency>
<!-- flad-dao -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-dao</artifactId>
</dependency>
</dependencies>
</project>
in flad-access i have my controller
HotelController
package com.lma.flad.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class HotelController {
private HotelRepository hotelRepository;
public HotelController(HotelRepository hotelRepository){
this.hotelRepository = hotelRepository;
}
@GetMapping("/hotels")
public List<Hotel> getHotels(){
List<Hotel> hotels = this.hotelRepository.findAll();
return hotels;
}
}
in flad-dao i have my entity Hotel and my HotelRepository
Hotel.java
public class Hotel {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private long id;
private String name;
private int classification;
private boolean isOpen;
protected Hotel(){}
}
HotelRepository
package com.lma.flad.repository;
import com.lma.flad.entity.Hotel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface HotelRepository extends JpaRepository<Hotel, Long> {
}
my root Application
FladApplication
package com.lma.flad.access;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class FladApplication {
public static void main(String[] args) {
SpringApplication.run(FladApplication.class, args);
}
}
After run FladApplication
so who has any idea how i fix this that please
Thank you
burtsevyg :
You should replace ${flad-version} to ${project.version}.
<dependencyManagement>
<dependencies>
<!-- flad-framework -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-framework</artifactId>
<version>${project.version}</version>
</dependency>
<!-- flad-dao -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-dao</artifactId>
<version>${project.version}</version>
</dependency>
<!-- flad-service -->
<dependency>
<groupId>com.lma</groupId>
<artifactId>flad-service</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
See pull request https://github.com/dali05/SpringBootMultipleMavenModules/pull/1
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=355819&siteId=1