JAVA两个模块间如何请求,有两个模块,如何让这两个模式的url地址能同时访问...

我现在有两个模块,abbott-system模块和abbott-generator模块

我的模块abbott-system有url为/exp/list 模块abbott-generator有url为/article/list,我希望启动模块abbott-system后,b模块的abbott-generator为/article/list也有效,请问怎么实现呢?abbott-system模块和abbott-generator使用不同的端口号

abbott-system模块

http://127.0.0.1:9091/abo/exp/findAll

这是url可以被访问到

我的启动函数在这个模块下

abbott-generator模块

http://127.0.0.1:9090/aggregation/v1?start=0&dataLength=100

这是url访问不到

abbott-system模块

这是启动文件,只有abbott-system模块的/article/list有效,abbott-generator为/article/list访问不了package cn;

//import cn.spring.inter.config.CorsFilter;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.context.annotation.ComponentScan;

/**

* 默认 SpringBoot 会扫描主类所在包 及子包下组件

*/

@SpringBootApplication

//@ComponentScan(basePackages= {"cn.spring.inter.controller"})//扫描组件

//@EntityScan("cn.spring.inter.bean")

//@EnableJpaRepositories("cn.spring.inter.repository")

//@MapperScan({"cn.spring.inter.*.Mapper","org.example.*.mapper"})

public class AbbottApplication {

public static void main(String[] args) {

SpringApplication.run(AbbottApplication.class, args);

}

// /**

// * 配置跨域访问的过滤器

// * @return

// */

// @Bean

// public FilterRegistrationBean registerFilter(){

// FilterRegistrationBean bean = new FilterRegistrationBean();

// bean.addUrlPatterns("/*");

// bean.setFilter(new CorsFilter());

// return bean;

// }

}package cn.spring.inter.controller;

import cn.spring.inter.bean.ResponseData;

import cn.spring.inter.entity.AbbottExperience;

import cn.spring.inter.service.AbbottExperienceService;

import com.alibaba.fastjson.JSON;

import com.alibaba.fastjson.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.RequestParam;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import java.util.Map;

@RestController

//@RequestMapping("/abo/exp")

public class AbbottExperienceController {

@Autowired

private AbbottExperienceService abbottExperienceService;

@RequestMapping("/abo/exp/findAll")

public List findAll(){

return abbottExperienceService.findAll();

}

@RequestMapping(value = "/abo/exp/v1/addOne", method={ RequestMethod.POST, RequestMethod.GET })

public ResponseData addOne(@RequestBody Map experience){

AbbottExperience abb=new AbbottExperience();

abb.setCompany(experience.get("company"));

abb.setInfo(experience.get("info"));

abbottExperienceService.addOne(abb);

// System.out.println(abb.getId());

ResponseData responseData = new ResponseData();

JSONObject jsonResultObject = new JSONObject();

responseData.setCode("0000");

responseData.setStatus("success");

responseData.setMessage("add");

responseData.setDetail("添加个人经历");

jsonResultObject.put("data", abb);

responseData.setResult(jsonResultObject);

return responseData;

}

@RequestMapping(value = "/abo/exp/v1/updateOne", method={ RequestMethod.POST, RequestMethod.GET })

public ResponseData updateOne(@RequestBody Map experience){

AbbottExperience abb=new AbbottExperience();

abb.setId(Integer.parseInt(experience.get("id")));

abb.setCompany(experience.get("company"));

abb.setInfo(experience.get("info"));

abbottExperienceService.updateOne(abb);

// System.out.println(abb.getId());

ResponseData responseData = new ResponseData();

JSONObject jsonResultObject = new JSONObject();

responseData.setCode("0000");

responseData.setStatus("success");

responseData.setMessage("add");

responseData.setDetail("添加个人经历");

jsonResultObject.put("data", abb);

responseData.setResult(jsonResultObject);

return responseData;

}

@RequestMapping(value="/abo/exp/v1",method=RequestMethod.GET)

public ResponseData getAll(

@RequestParam(value="start", required=false,defaultValue = "0") Integer start,

@RequestParam(value="dataLength", required=false,defaultValue = "100") Integer dataLength){

// System.out.println("start="+start+"/dataLength="+dataLength);

ResponseData responseData = new ResponseData();

JSONObject jsonResultObject = new JSONObject();

responseData.setCode("200");

responseData.setStatus("success");

responseData.setMessage("abbottExperiences");

responseData.setDetail("查询Experiences");

List abbottExperienceList = abbottExperienceService.getAll(start, dataLength);

jsonResultObject.put("experience", abbottExperienceList);

responseData.setData(jsonResultObject);

return responseData;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值