Maven configuration with Spring Boot & multi modules - run application in Intellij

前端 未结 3 1348
闹比i
闹比i 2020-12-08 16:09

I\'m currently working on a REST API with Spring Boot.

I\'m new to Maven and have just started coding with IDEA (don\'t know well this IDE yet), and I have a problem

3条回答
  •  伪装坚强ぢ
    2020-12-08 16:44

    Your project structured as:

    • parent
      • pom.xml
      • main module
        • controller
        • domain
        • App.java (Spring Boot main class)
        • pom.xml (add sub moudle to main module as dependency)
      • sub module
        • controllers
        • domain
        • pom.xm

    if your App.java in a package: com.xxxx.pro,then set the sub module's package is com.xxx.pro,such as your sub module's controller is TestController.java, and the code is:

    package com.xx.pro.web;
    @RestController
    public class TestController{
    
    }
    

    so, this sub moudle's TestController will be sanned by App.java.Try it on, good luck.

提交回复
热议问题