一、ideal新建項目1
ideal新建項目2
至此父項目就創建好了,下面創建多模塊:
填好之后點擊create
不刪了,直接改包名,看自己喜歡
修改包名和啟動類名:
打開ServiceApplication啟動類,修改如下:
package org.wen;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;/*** Hello world!**/
@SpringBootApplication(scanBasePackages = {"org.example.*"})
public class ServiceApplication
{public static void main( String[] args ){SpringApplication.run(ServiceApplication.class);System.out.println( "Hello World!" );}
}
右鍵啟動一下:
說明已經可以正常啟動,下面再新建一個business模塊,按照上面的操作再執行一遍就好
business模塊去掉啟動類,直接寫業務代碼,要想在service模塊啟動,能訪問到business模塊,需要在service模塊pom.xml配置依賴:
<dependencies><dependency><groupId>wen.business</groupId><artifactId>wen-business</artifactId><version>1.0-SNAPSHOT</version></dependency></dependencies>
配置好之后,重新啟動訪問一下:
http://localhost:8080/test/hello
出現hello表示項目已經啟動成功并可以順利訪問到business模塊