项目共三个模块;
- service(Service层,提供服务给controller层调用,数据类型为BO
- integration(适配层,调用提供者提供的服务,导入jar包依赖,数据类型为TO(涉及数据传输,主要序列化
- main(Controller层,前端请求Controller,前端传递的数据类型为Request,转为BO作为Service层的参数
项目入口为main模块中的GatewayApplication.java,调用了treefinance-b2b-loangateway-main-spring.xml
package com.treefinance.b2b.loangateway.main.server;
import com.treefinance.springboot.sso.annotation.EnableLoanSsoAuth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@ServletComponentScan
@ImportResource(value = {"spring/treefinance-b2b-loangateway-main-spring.xml"})
@EnableScheduling
//@EnableLoanSsoAuth
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}
treefinance-b2b-loangateway-main-spring.xml代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<context:component-scan base-package="com.treefinance.b2b.loangateway.main"/>
<context:property-placeholder location="classpath:/config/treefinance-b2b-loangateway-main.properties"
ignore-unresolvable="true"/>
<aop:aspectj-autoproxy/>
<import resource="classpath*:spring/dashu-diamond-spring.xml"/>
<import resource="classpath*:spring/treefinance-b2b-loangateway-biz-service-spring.xml"/>
<import resource="classpath*:spring/treefinance-b2b-loangateway-main-dubbo-registry.xml"/>
</beans>
treefinance-b2b-loangateway-main-spring.xml功能如下
- 扫描了com.treefinance.b2b.loangateway.main包,treefinance-b2b-loangateway-main.properties文件内容为空;
- 导入service模块下spring/treefinance-b2b-loangateway-biz-service-spring.xml配置文件;classpath*(带*);
- 导入自身模块下spring/treefinance-b2b-loangateway-main-dubbo-registry.xml配置文件;classpath*(带*);
- 自身模块下spring/treefinance-b2b-loangateway-main-dubbo-registry.xml中
- 配置了<dubbo:application name="treefinance-b2b-loangateway"/>(和项目名一致)
- 配置了<dubbo:registry address="${dubbo.registry.address}"/>(和注册中心中的provider地址一致)
-
导入了<import resource="classpath:/spring/treefinance-b2b-loangateway-common-dubbo-integration.xml"/>配置文件(integration层的文件,配置了<dubbo:reference interface = "com.treefinance.b2b.loan.debtorcenter.common.facade.loandebtor.interfaces.DebtorEnterpriseFacadeService" id="debtorEnterpriseFacadeService" check="false"/>,id的属性要与注册中心提供服务的id名一致)
-
service模块下spring/treefinance-b2b-loangateway-biz-service-spring.xml
-
扫描"com.treefinance.b2b.loangateway.biz.service"包,property文件配置也为空
-
导入<import resource="classpath:/spring/treefinance-b2b-loangateway-common-integration-spring.xml"/>
配置文件(intergration模块代码)
-
导入<import resource="classpath:/spring/treefinance-b2b-loangateway-common-utils-spring.xml"/>
配置文件(Util模块代码,项目没怎么用到)
-