#32 multi module: use common module
This commit is contained in:
2
multimodule/module-api/demo.http
Normal file
2
multimodule/module-api/demo.http
Normal file
@@ -0,0 +1,2 @@
|
||||
###
|
||||
GET http://localhost:8080/save
|
||||
@@ -3,7 +3,12 @@ package com.example.moduleapi;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(
|
||||
scanBasePackages = {
|
||||
"com.example.moduleapi",
|
||||
"com.example.modulecommon"
|
||||
}
|
||||
)
|
||||
public class ModuleApiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.example.moduleapi.controller;
|
||||
|
||||
import com.example.moduleapi.service.DemoService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class DemoController {
|
||||
|
||||
private final DemoService demoService;
|
||||
|
||||
@GetMapping("save")
|
||||
public String save() {
|
||||
return demoService.save();
|
||||
}
|
||||
|
||||
@GetMapping("/find")
|
||||
public String find() {
|
||||
return demoService.find();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.example.moduleapi.service;
|
||||
|
||||
import com.example.modulecommon.enums.CodeEnum;
|
||||
import com.example.modulecommon.sevice.CommonDemoService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DemoService {
|
||||
|
||||
private final CommonDemoService commonDemoService;
|
||||
|
||||
public String save() {
|
||||
System.out.println(CodeEnum.SUCCESS.getCode());
|
||||
System.out.println(commonDemoService.commonService());
|
||||
return "save";
|
||||
}
|
||||
|
||||
public String find() {
|
||||
return "find";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.example.modulecommon.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CodeEnum {
|
||||
SUCCESS("0000", "SUCCESS"),
|
||||
UNKNOWN_ERROR("9999", "UNKNOWN_ERROR"),
|
||||
;
|
||||
|
||||
|
||||
private final String code;
|
||||
private final String message;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.example.modulecommon.sevice;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CommonDemoService {
|
||||
|
||||
public String commonService() {
|
||||
return "commonService";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user