[CI、CD入门]maven打包可执行程序之微服务-服务提供者篇
前言
持续构建,自动部署这个机制必须要落实到具体开发任务中,光是写几个demo编译最简单的程序或者web意义不大。
本篇文章将用现有的微服务框架程序作为例子,说明主要打包流程。
微服务项目框架及目录说明
API子项目说明
这里先说明一下微服务项目的目录结构
首先每一个微服务都划分为两个子项目,分别是:API接口调用层,及APP程序执行主体。
目的是:api子项目用于导出到本地仓库,作为其他微服务的第三方库,可导入进行调用,方便维护;APP子项目用于进行进行打包分发,扔给运维进行部署以及执行
API子项目结构:
这里的项目结构根据个人而异,挑重点来说,biz–业务层,service-数据库服务层,model–数据库表模型,用于插入记录,更新记录,vo–view object,数据库表的界面模型,注意,model及vo一开始是相同的,然而随着开发的进行大家会发现,vo是很有必要的,seracher–单表搜索层,就是用于搜索某张表的记录用得。
resources下面分别有 consumer,consumer4biz及consumer4service配置文件,注意,重点提一下这些文件的用处:
<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
">
<!--<!–接口调用–>-->
<!--<dubbo:reference id="MicroBase.account.MemberRoleService"-->
<!--interface="net.w2p.MicroBase.service.account.MemberRoleService"/>-->
<!--<!–接口调用 end–>-->
<import resource="classpath:conf/dubbo/MicroBase-consumer4service.xml"></import>
<import resource="classpath:conf/dubbo/MicroBase-consumer4biz.xml"></import>
</beans>
MicroBase-consumer.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:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
">
<!--biz复合业务层 调用接口-->
<!--account 子模块 begin-->
<!--Account begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.account.AccountBiz"
id="MicroBase.biz.AccountBiz"
/>
<!--Account end-->
<!--Attention begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.account.AttentionBiz"
id="MicroBase.biz.account.AttentionBiz"
/>
<!--Attention end-->
<!--account 子模块 end-->
<!--cms 子模块 begin -->
<!--Article begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.cms.ArticleBiz"
id="MicroBase.biz.cms.ArticleBiz"
/>
<!--Article end-->
<!--cms 子模块 end -->
<!--common 子模块 begin -->
<!--CustomForm begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.common.CustomFormBiz"
id="MicroBase.biz.common.CustomFormBiz"
/>
<!--CustomForm end-->
<!--FeedBack begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.common.FeedBackBiz"
id="MicroBase.biz.common.FeedBackBiz"
/>
<!--FeedBack end-->
<!--Region begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.common.RegionBiz"
id="MicroBase.biz.common.RegionBiz"
/>
<!--Region end-->
<!--Tag begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.common.TagBiz"
id="MicroBase.biz.common.TagBiz"
/>
<!--Tag end-->
<!--Ticket begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.common.TicketBiz"
id="MicroBase.biz.common.TicketBiz"
/>
<!--Ticket end-->
<!--VerifyCode begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.common.VerifyCodeBiz"
id="MicroBase.biz.common.VerifyCodeBiz"
/>
<!--VerifyCode end-->
<!--common 子模块 end -->
<!--information 子模块 begin -->
<!--SiteMail begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.information.SiteMailBiz"
id="MicroBase.biz.information.SiteMailBiz"
/>
<!--SiteMail end-->
<!--SysMsg begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.information.SysMsgBiz"
id="MicroBase.biz.information.SysMsgBiz"
/>
<!--SysMsg end-->
<!--information 子模块 end -->
<!--plugins 子模块 begin -->
<!--Email begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.plugins.EmailBiz"
id="MicroBase.biz.plugins.EmailBiz"
/>
<!--Email end-->
<!--Sms begin-->
<dubbo:reference interface="net.w2p.MicroBase.biz.plugins.SmsBiz"
id="MicroBase.biz.plugins.SmsBiz"
/>
<!--Sms end-->
<!--plugins 子模块 end -->
</beans>
MicroBase-consumer4biz.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:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
">
<!--account 子模块 begin-->
<!--MemberRole begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.account.MemberRoleService"
id="MicroBase.account.MemberRoleService"
/>
<!--MemberRole end-->
<!--Member begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.account.MemberService"
id="MicroBase.account.MemberService"
/>
<!--Member end-->
<!--CorpMember begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.account.CorpMemberService"
id="MicroBase.account.CorpMemberService"
/>
<!--CorpMember end-->
<!--Corporation begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.account.CorporationService"
id="MicroBase.account.CorporationService"
/>
<!--Corporation end-->
<!--MemberAttention begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.account.MemberAttentionService"
id="MicroBase.account.MemberAttentionService"
/>
<!--MemberAttention end-->
<!--account 子模块 end-->
<!--cms 子模块 begin -->
<!--ArticleCategory begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.cms.ArticleCategoryService"
id="MicroBase.cms.ArticleCategoryService"
/>
<!--ArticleCategory end-->
<!--Article begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.cms.ArticleService"
id="MicroBase.cms.ArticleService"
/>
<!--Article end-->
<!--cms 子模块 end -->
<!--common 子模块 begin -->
<!--AdsCategory begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.AdsCategoryService"
id="MicroBase.common.AdsCategoryService"
/>
<!--AdsCategory end-->
<!--Advertisement begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.AdvertisementService"
id="MicroBase.common.AdvertisementService"
/>
<!--Advertisement end-->
<!--CommonFile begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.CommonFileService"
id="MicroBase.common.CommonFileService"
/>
<!--CommonFile end-->
<!--CommonImage begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.CommonImageService"
id="MicroBase.common.CommonImageService"
/>
<!--CommonImage end-->
<!--Config begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.ConfigService"
id="MicroBase.common.ConfigService"
/>
<!--Config end-->
<!--ConfigSet begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.ConfigSetService"
id="MicroBase.common.ConfigSetService"
/>
<!--ConfigSet end-->
<!--DictCate begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.DictCateService"
id="MicroBase.common.DictCateService"
/>
<!--DictCate end-->
<!--DictItem begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.DictItemService"
id="MicroBase.common.DictItemService"
/>
<!--DictItem end-->
<!--FeedBack begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.FeedBackService"
id="MicroBase.common.FeedBackService"
/>
<!--FeedBack end-->
<!--FieldOption begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.FieldOptionService"
id="MicroBase.common.FieldOptionService"
/>
<!--FieldOption end-->
<!--FormField begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.FormFieldService"
id="MicroBase.common.FormFieldService"
/>
<!--FormField end-->
<!--FormResult begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.FormResultService"
id="MicroBase.common.FormResultService"
/>
<!--FormResult end-->
<!--Form begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.FormService"
id="MicroBase.common.FormService"
/>
<!--Form end-->
<!--Region begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.RegionService"
id="MicroBase.common.RegionService"
/>
<!--Region end-->
<!--ResultItem begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.ResultItemService"
id="MicroBase.common.ResultItemService"
/>
<!--ResultItem end-->
<!--Tag begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.TagService"
id="MicroBase.common.TagService"
/>
<!--Tag end-->
<!--Ticket begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.TicketService"
id="MicroBase.common.TicketService"
/>
<!--Ticket end-->
<!--TicketCollection begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.TicketCollectionService"
id="MicroBase.common.TicketCollectionService"
/>
<!--TicketCollection end-->
<!--VerifyCode begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.common.VerifyCodeService"
id="MicroBase.common.VerifyCodeService"
/>
<!--VerifyCode end-->
<!--common 子模块 end -->
<!--information 子模块 begin -->
<!--MsgState begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.information.MsgStateService"
id="MicroBase.information.MsgStateService"
/>
<!--MsgState end-->
<!--SiteMail begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.information.SiteMailService"
id="MicroBase.information.SiteMailService"
/>
<!--SiteMail end-->
<!--SiteMailState begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.information.SiteMailStateService"
id="MicroBase.information.SiteMailStateService"
/>
<!--SiteMailState end-->
<!--SiteMailTo begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.information.SiteMailToService"
id="MicroBase.information.SiteMailToService"
/>
<!--SiteMailTo end-->
<!--SysMsgOwner begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.information.SysMsgOwnerService"
id="MicroBase.information.SysMsgOwnerService"
/>
<!--SysMsgOwner end-->
<!--SysMsg begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.information.SysMsgService"
id="MicroBase.information.SysMsgService"
/>
<!--SysMsg end-->
<!--information 子模块 end -->
<!--logs 子模块 begin -->
<!--EmailLog begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.logs.EmailLogService"
id="MicroBase.logs.EmailLogService"
/>
<!--EmailLog end-->
<!--SmsLog begin-->
<dubbo:reference interface="net.w2p.MicroBase.service.logs.SmsLogService"
id="MicroBase.logs.SmsLogService"
/>
<!--SmsLog end-->
<!--logs 子模块 end -->
</beans>
MicroBase-consumer4service.xml内容
看到这里,假如有用过dubbo的就会知道,这两个文件合成一个consumer.xml文件,是dubbo提供的消费者调用列表的配置文件,任何一个需要调用dubbo服务的程序必然要引入这份文件的。
例如,这样引用:
当然,要引用时候请先在maven中导入该jar文件,例如:
<dependency>
<groupId>net.w2p</groupId>
<artifactId>MicroBaseApi</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
话说这样手工填写也是很麻烦的,不过暂时找不到优化方案
好了,另一个重要文件就是pom文件了:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>micro-base</artifactId>
<groupId>net.w2p</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MicroBaseApi</artifactId>
<!--当前项目为微服务模块的对外接口部分,提取出来顺便打包到内部maven用来给其他模块进行调用的。-->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--基础类库-->
<dependency>
<!--Group net.funfunle-->
<!--Name baselib-->
<groupId>net.funfunle</groupId>
<artifactId>baselib</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<!--基础类库 end-->
<!--引入消息队列客户端 begin -->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-common</artifactId>
<version>4.2.0</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.2.0</version>
</dependency>
<!--<dependency>-->
<!--<groupId>io.netty</groupId>-->
<!--<artifactId>netty-tcnative</artifactId>-->
<!--<version>1.1.33.FORK22</version>-->
<!--</dependency>-->
<!--引入消息队列客户端 end -->
</dependencies>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://你自己的本地仓库/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://你自己的本地仓库/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
值得注意的是,每次构建都要deploy到本地仓库,更新一下:
APP子项目说明
目录说明
在src main assembly下面有一个assembly配置文件,作用为将所有主体程序需要的用到的资源,第三方类库,项目jar进行打包,下面是设置的内容:
<?xml version='1.0' encoding='UTF-8'?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<!--<id>demo</id>-->
<!--<formats>-->
<!--<format>jar</format>-->
<!--</formats>-->
<!--算了,assembly的id好听一点-->
<id>Build</id>
<!-- 最终打包成一个用于发布的zip文件 -->
<formats>
<format>zip</format>
</formats>
<!-- Adds dependencies to zip package under lib directory -->
<dependencySets>
<dependencySet>
<!--
不使用项目的artifact,第三方jar不要解压,打包进zip文件的lib目录
-->
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
<fileSets>
<!-- 把项目相关的说明文件,打包进zip文件的根目录 -->
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>README*</include>
<include>LICENSE*</include>
<include>NOTICE*</include>
</includes>
</fileSet>
<!-- 把项目的配置文件,打包进zip文件的config目录 -->
<fileSet>
<directory>${project.basedir}\src\main\config</directory>
<outputDirectory>config</outputDirectory>
<includes>
<include>*.xml</include>
<include>*.properties</include>
</includes>
</fileSet>
<!-- 把项目的脚本文件目录( src/main/scripts )中的启动脚本文件,打包进zip文件的跟目录 -->
<fileSet>
<directory>${project.build.scriptSourceDirectory}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>startup.*</include>
</includes>
</fileSet>
<!-- 把项目的脚本文件(除了启动脚本文件),打包进zip文件的script目录 -->
<fileSet>
<directory>${project.build.scriptSourceDirectory}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>startup.*</include>
</includes>
</fileSet>
<!-- 把项目自己编译出来的jar文件,打包进zip文件的根目录 -->
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
dao是mybatis自动映射的mapper类,用于操作数据库,里面都是interface,下面将接口及mybatis的xml配置文件抄一份demo出来:
注意,本项目用得数据库是postgresql,所以不是mysql的语法来的。
package net.w2p.MicroBase.dao.account;
import net.w2p.MicroBase.dao.account.MemberMapper;
import net.w2p.MicroBase.model.account.MemberModel;
import net.w2p.MicroBase.vo.account.Member;
import net.w2p.MicroBase.searcher.account.MemberCondition;
//import net.w2p.MicroBase.service.account.MemberService;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
import java.util.List;
public interface MemberMapper {
public ArrayList<Member> fetchAccount(@Param(value = "mobile") String mobile, @Param(value = "email") String email);
//--通用方法
public ArrayList<Member> simpleSearch(@Param(value = "condition") MemberCondition condition);
public Integer fetchSize(@Param(value = "condition") MemberCondition condition);
public int writeEntireRecord(@Param(value = "model") MemberModel model);
public int updateRecordByCondition(@Param(value = "model") MemberModel model, @Param(value = "condition") MemberCondition condition);
public int deleteByCondition(@Param(value = "condition") MemberCondition condition);
public int clearColumnByCondition(@Param(value = "condition") MemberCondition condition, @Param(value = "list") ArrayList<String> columns);
//--以下方法只有拥有主键的表才能使用。
public Member fetchDetail(@Param(value = "id") Long id);
public int insertRecord(@Param(value = "model") MemberModel model);
public int updateRecord(@Param(value = "model") MemberModel model);
public int deleteRecord(@Param(value = "id") Long id);
public int clearColumnById(@Param(value = "id") Long id, @Param(value = "list") ArrayList<String> columns);
}
MemberMapper.java
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.w2p.MicroBase.dao.account.MemberMapper">
<select id="fetchAccount" resultType="net.w2p.MicroBase.vo.account.Member">
select * from(
select
m.*,
cr.name as region_name
from member m left join common_region cr on cr.id=m.region_id
)
as temp_table
<trim prefix="where" prefixOverrides="and |or">
<if test="mobile!=null"><![CDATA[ or "mobile" = #{mobile} ]]></if>
<if test="email!=null"><![CDATA[ or "email" = #{email} ]]></if>
</trim>
</select>
<select id="simpleSearch" resultType="net.w2p.MicroBase.vo.account.Member">
select * from(
select
m.*,
cr.name as region_name
from member m left join common_region cr on cr.id=m.region_id
)
as temp_table
<if test="condition != null">
<trim prefix="where" prefixOverrides="and |or">
<include refid="base_where_condition_for_Member"/>
</trim>
</if>
<choose>
<when test="condition != null and condition.orderConditions!=null and condition.orderConditions.size() > 0">
<trim prefix=" order by " suffixOverrides=",">
<foreach collection="condition.orderConditions" index="index" item="item" open="" separator=""
close="">
<if test='item.columnName!=null and item.columnName=="id"'>
"id"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="name"'>
"name"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="email"'>
"email"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="mobile"'>
"mobile"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="password"'>
"password"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="avatar"'>
"avatar"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="regist_time"'>
"regist_time"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="token"'>
"token"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="longitude"'>
"longitude"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="latitude"'>
"latitude"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="wxopenid"'>
"wxopenid"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="unionid"'>
"unionid"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="qqkey"'>
"qqkey"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="login_time"'>
"login_time"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="last_login_time"'>
"last_login_time"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="region_id"'>
"region_id"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="address"'>
"address"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="member_status"'>
"member_status"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
<if test='item.columnName!=null and item.columnName=="data_completed"'>
"data_completed"
<choose>
<when test='item.orderType=="desc"'>desc</when>
<otherwise>asc</otherwise>
</choose>
,
</if>
</foreach>
</trim>
</when>
<otherwise>
order by "id" desc
</otherwise>
</choose>
<if test="_parameter !=null">
<if test="condition.pager_begin_index != null and condition.pager_limit !=null">
limit #{condition.pager_limit} offset #{condition.pager_begin_index}
</if>
</if>
</select>
<select id="fetchSize" resultType="Integer">
select
count(*)
from member
<if test="condition != null">
<trim prefix="where" prefixOverrides="and |or">
<include refid="base_where_condition_for_Member"/>
</trim>
</if>
</select>
<!--插入所有字段的一条记录。-->
<insert id="writeEntireRecord">
insert into member
<include refid="base_write_entire_values_for_Member"/>
</insert>
<update id="updateRecordByCondition">
UPDATE member
<trim prefix="set" suffixOverrides=",">
<include refid="base_update_set_values_for_Member"/>
</trim>
WHERE
<trim prefix="" prefixOverrides="and |or">
<include refid="base_where_condition_for_Member"/>
</trim>
</update>
<update id="clearColumnByCondition">
UPDATE member
set
<trim prefix="" suffixOverrides=",">
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="name"'>"name"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="email"'>"email"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="mobile"'>"mobile"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="password"'>"password"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="avatar"'>"avatar"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="regist_time"'>"regist_time"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="token"'>"token"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="longitude"'>"longitude"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="latitude"'>"latitude"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="wxopenid"'>"wxopenid"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="unionid"'>"unionid"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="qqkey"'>"qqkey"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="login_time"'>"login_time"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="last_login_time"'>"last_login_time"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="region_id"'>"region_id"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="address"'>"address"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="member_status"'>"member_status"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="data_completed"'>"data_completed"=null,</if>
</foreach>
</trim>
WHERE
<trim prefix="" prefixOverrides="and |or">
<include refid="base_where_condition_for_Member"/>
</trim>
</update>
<delete id="deleteByCondition">
delete from member
WHERE
<if test="_parameter != null">
<trim prefix="" prefixOverrides="and |or">
<include refid="base_where_condition_for_Member"/>
</trim>
</if>
</delete>
<!--begin 这是增删改查的完全生成-->
<!--插入一条记录,注意,插入记录的时候最好还是全部数据都插入一次,因为您永远不会知道哪些字段会报null错误。-->
<insert id="insertRecord">
<selectKey keyProperty="model.id" resultType="java.lang.Long" order="AFTER">
<!--SELECT currval('serial_member_id') -->
SELECT currval('member_id_seq')
</selectKey>
insert into member
<include refid="base_insert_values_for_Member"/>
</insert>
<!--更新操作-->
<update id="updateRecord">
UPDATE member
<trim prefix="set" suffixOverrides=",">
<include refid="base_update_set_values_for_Member"/>
</trim>
WHERE "id"=#{model.id}
</update>
<update id="clearColumnById">
UPDATE member
set
<trim prefix="" suffixOverrides=",">
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="name"'>"name"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="email"'>"email"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="mobile"'>"mobile"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="password"'>"password"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="avatar"'>"avatar"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="regist_time"'>"regist_time"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="token"'>"token"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="longitude"'>"longitude"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="latitude"'>"latitude"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="wxopenid"'>"wxopenid"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="unionid"'>"unionid"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="qqkey"'>"qqkey"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="login_time"'>"login_time"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="last_login_time"'>"last_login_time"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="region_id"'>"region_id"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="address"'>"address"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="member_status"'>"member_status"=null,</if>
</foreach>
<foreach item="item" index="index" collection="list" open="" separator="," close="">
<if test='item=="data_completed"'>"data_completed"=null,</if>
</foreach>
</trim>
WHERE "id"=#{id}
</update>
<select id="fetchDetail" resultType="net.w2p.MicroBase.vo.account.Member"
parameterType="int">
select * from(
select
m.*,
cr.name as region_name
from member m left join common_region cr on cr.id=m.region_id
)
as temp_table
<trim prefix="where" prefixOverrides="and |or">
id = #{id}
</trim>
</select>
<delete id="deleteRecord" parameterType="Long">
delete from member
WHERE "id"=#{id}
</delete>
<!--end 这是增删改查的完全生成-->
<!--sql 部件-->
<sql id="base_where_condition_for_Member">
<!--基础生成的where condition 根据单标结构-->
<if test="condition.id!=null and condition.id.EQUAL_TO!=null">
<![CDATA[ and "id" = #{condition.id.EQUAL_TO}]]>
</if>
<if test="condition.id!=null and condition.id.NOT_EQUAL_TO!=null">
<![CDATA[ and "id" <> #{condition.id.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.id!=null and condition.id.MORE_THAN!=null">
<![CDATA[ and "id" > #{condition.id.MORE_THAN}]]>
</if>
<if test="condition.id!=null and condition.id.LESS_THAN!=null">
<![CDATA[ and "id" < #{condition.id.LESS_THAN} ]]>
</if>
<if test="condition.id!=null and condition.id.IN!=null">
and "id" in
<foreach collection="condition.id.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.id!=null and condition.id.NOT_IN!=null">
and "id" not in
<foreach collection="condition.id.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.name!=null and condition.name.EQUAL_TO!=null">
<![CDATA[ and "name" = #{condition.name.EQUAL_TO} ]]>
</if>
<if test="condition.name!=null and condition.name.NOT_EQUAL_TO!=null">
<![CDATA[ and "name" <> #{condition.name.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.name!=null and condition.name.LIKE!=null">
and "name" LIKE CONCAT('%',#{condition.name.LIKE},'%')
</if>
<if test="condition.name!=null and condition.name.IN!=null">
and "name" in
<foreach collection="condition.name.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.name!=null and condition.name.NOT_IN!=null">
and "name" not in
<foreach collection="condition.name.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.email!=null and condition.email.EQUAL_TO!=null">
<![CDATA[ and "email" = #{condition.email.EQUAL_TO} ]]>
</if>
<if test="condition.email!=null and condition.email.NOT_EQUAL_TO!=null">
<![CDATA[ and "email" <> #{condition.email.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.email!=null and condition.email.LIKE!=null">
and "email" LIKE CONCAT('%',#{condition.email.LIKE},'%')
</if>
<if test="condition.email!=null and condition.email.IN!=null">
and "email" in
<foreach collection="condition.email.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.email!=null and condition.email.NOT_IN!=null">
and "email" not in
<foreach collection="condition.email.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.mobile!=null and condition.mobile.EQUAL_TO!=null">
<![CDATA[ and "mobile" = #{condition.mobile.EQUAL_TO} ]]>
</if>
<if test="condition.mobile!=null and condition.mobile.NOT_EQUAL_TO!=null">
<![CDATA[ and "mobile" <> #{condition.mobile.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.mobile!=null and condition.mobile.LIKE!=null">
and "mobile" LIKE CONCAT('%',#{condition.mobile.LIKE},'%')
</if>
<if test="condition.mobile!=null and condition.mobile.IN!=null">
and "mobile" in
<foreach collection="condition.mobile.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.mobile!=null and condition.mobile.NOT_IN!=null">
and "mobile" not in
<foreach collection="condition.mobile.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.password!=null and condition.password.EQUAL_TO!=null">
<![CDATA[ and "password" = #{condition.password.EQUAL_TO} ]]>
</if>
<if test="condition.password!=null and condition.password.NOT_EQUAL_TO!=null">
<![CDATA[ and "password" <> #{condition.password.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.password!=null and condition.password.LIKE!=null">
and "password" LIKE CONCAT('%',#{condition.password.LIKE},'%')
</if>
<if test="condition.password!=null and condition.password.IN!=null">
and "password" in
<foreach collection="condition.password.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.password!=null and condition.password.NOT_IN!=null">
and "password" not in
<foreach collection="condition.password.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.avatar!=null and condition.avatar.EQUAL_TO!=null">
<![CDATA[ and "avatar" = #{condition.avatar.EQUAL_TO} ]]>
</if>
<if test="condition.avatar!=null and condition.avatar.NOT_EQUAL_TO!=null">
<![CDATA[ and "avatar" <> #{condition.avatar.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.avatar!=null and condition.avatar.LIKE!=null">
and "avatar" LIKE CONCAT('%',#{condition.avatar.LIKE},'%')
</if>
<if test="condition.avatar!=null and condition.avatar.IN!=null">
and "avatar" in
<foreach collection="condition.avatar.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.avatar!=null and condition.avatar.NOT_IN!=null">
and "avatar" not in
<foreach collection="condition.avatar.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.regist_time!=null and condition.regist_time.EQUAL_TO!=null">
<![CDATA[ and "regist_time" = #{condition.regist_time.EQUAL_TO}]]>
</if>
<if test="condition.regist_time!=null and condition.regist_time.NOT_EQUAL_TO!=null">
<![CDATA[ and "regist_time" <> #{condition.regist_time.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.regist_time!=null and condition.regist_time.MORE_THAN!=null">
<![CDATA[ and "regist_time" > #{condition.regist_time.MORE_THAN}]]>
</if>
<if test="condition.regist_time!=null and condition.regist_time.LESS_THAN!=null">
<![CDATA[ and "regist_time" < #{condition.regist_time.LESS_THAN} ]]>
</if>
<if test="condition.token!=null and condition.token.EQUAL_TO!=null">
<![CDATA[ and "token" = #{condition.token.EQUAL_TO} ]]>
</if>
<if test="condition.token!=null and condition.token.NOT_EQUAL_TO!=null">
<![CDATA[ and "token" <> #{condition.token.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.token!=null and condition.token.LIKE!=null">
and "token" LIKE CONCAT('%',#{condition.token.LIKE},'%')
</if>
<if test="condition.token!=null and condition.token.IN!=null">
and "token" in
<foreach collection="condition.token.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.token!=null and condition.token.NOT_IN!=null">
and "token" not in
<foreach collection="condition.token.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.longitude!=null and condition.longitude.EQUAL_TO!=null">
<![CDATA[ and "longitude" = #{condition.longitude.EQUAL_TO}]]>
</if>
<if test="condition.longitude!=null and condition.longitude.NOT_EQUAL_TO!=null">
<![CDATA[ and "longitude" <> #{condition.longitude.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.longitude!=null and condition.longitude.MORE_THAN!=null">
<![CDATA[ and "longitude" > #{condition.longitude.MORE_THAN}]]>
</if>
<if test="condition.longitude!=null and condition.longitude.LESS_THAN!=null">
<![CDATA[ and "longitude" < #{condition.longitude.LESS_THAN} ]]>
</if>
<if test="condition.longitude!=null and condition.longitude.IN!=null">
and "longitude" in
<foreach collection="condition.longitude.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.longitude!=null and condition.longitude.NOT_IN!=null">
and "longitude" not in
<foreach collection="condition.longitude.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.latitude!=null and condition.latitude.EQUAL_TO!=null">
<![CDATA[ and "latitude" = #{condition.latitude.EQUAL_TO}]]>
</if>
<if test="condition.latitude!=null and condition.latitude.NOT_EQUAL_TO!=null">
<![CDATA[ and "latitude" <> #{condition.latitude.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.latitude!=null and condition.latitude.MORE_THAN!=null">
<![CDATA[ and "latitude" > #{condition.latitude.MORE_THAN}]]>
</if>
<if test="condition.latitude!=null and condition.latitude.LESS_THAN!=null">
<![CDATA[ and "latitude" < #{condition.latitude.LESS_THAN} ]]>
</if>
<if test="condition.latitude!=null and condition.latitude.IN!=null">
and "latitude" in
<foreach collection="condition.latitude.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.latitude!=null and condition.latitude.NOT_IN!=null">
and "latitude" not in
<foreach collection="condition.latitude.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.wxopenid!=null and condition.wxopenid.EQUAL_TO!=null">
<![CDATA[ and "wxopenid" = #{condition.wxopenid.EQUAL_TO} ]]>
</if>
<if test="condition.wxopenid!=null and condition.wxopenid.NOT_EQUAL_TO!=null">
<![CDATA[ and "wxopenid" <> #{condition.wxopenid.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.wxopenid!=null and condition.wxopenid.LIKE!=null">
and "wxopenid" LIKE CONCAT('%',#{condition.wxopenid.LIKE},'%')
</if>
<if test="condition.wxopenid!=null and condition.wxopenid.IN!=null">
and "wxopenid" in
<foreach collection="condition.wxopenid.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.wxopenid!=null and condition.wxopenid.NOT_IN!=null">
and "wxopenid" not in
<foreach collection="condition.wxopenid.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.unionid!=null and condition.unionid.EQUAL_TO!=null">
<![CDATA[ and "unionid" = #{condition.unionid.EQUAL_TO} ]]>
</if>
<if test="condition.unionid!=null and condition.unionid.NOT_EQUAL_TO!=null">
<![CDATA[ and "unionid" <> #{condition.unionid.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.unionid!=null and condition.unionid.LIKE!=null">
and "unionid" LIKE CONCAT('%',#{condition.unionid.LIKE},'%')
</if>
<if test="condition.unionid!=null and condition.unionid.IN!=null">
and "unionid" in
<foreach collection="condition.unionid.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.unionid!=null and condition.unionid.NOT_IN!=null">
and "unionid" not in
<foreach collection="condition.unionid.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.qqkey!=null and condition.qqkey.EQUAL_TO!=null">
<![CDATA[ and "qqkey" = #{condition.qqkey.EQUAL_TO} ]]>
</if>
<if test="condition.qqkey!=null and condition.qqkey.NOT_EQUAL_TO!=null">
<![CDATA[ and "qqkey" <> #{condition.qqkey.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.qqkey!=null and condition.qqkey.LIKE!=null">
and "qqkey" LIKE CONCAT('%',#{condition.qqkey.LIKE},'%')
</if>
<if test="condition.qqkey!=null and condition.qqkey.IN!=null">
and "qqkey" in
<foreach collection="condition.qqkey.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.qqkey!=null and condition.qqkey.NOT_IN!=null">
and "qqkey" not in
<foreach collection="condition.qqkey.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.login_time!=null and condition.login_time.EQUAL_TO!=null">
<![CDATA[ and "login_time" = #{condition.login_time.EQUAL_TO}]]>
</if>
<if test="condition.login_time!=null and condition.login_time.NOT_EQUAL_TO!=null">
<![CDATA[ and "login_time" <> #{condition.login_time.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.login_time!=null and condition.login_time.MORE_THAN!=null">
<![CDATA[ and "login_time" > #{condition.login_time.MORE_THAN}]]>
</if>
<if test="condition.login_time!=null and condition.login_time.LESS_THAN!=null">
<![CDATA[ and "login_time" < #{condition.login_time.LESS_THAN} ]]>
</if>
<if test="condition.last_login_time!=null and condition.last_login_time.EQUAL_TO!=null">
<![CDATA[ and "last_login_time" = #{condition.last_login_time.EQUAL_TO}]]>
</if>
<if test="condition.last_login_time!=null and condition.last_login_time.NOT_EQUAL_TO!=null">
<![CDATA[ and "last_login_time" <> #{condition.last_login_time.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.last_login_time!=null and condition.last_login_time.MORE_THAN!=null">
<![CDATA[ and "last_login_time" > #{condition.last_login_time.MORE_THAN}]]>
</if>
<if test="condition.last_login_time!=null and condition.last_login_time.LESS_THAN!=null">
<![CDATA[ and "last_login_time" < #{condition.last_login_time.LESS_THAN} ]]>
</if>
<if test="condition.region_id!=null and condition.region_id.EQUAL_TO!=null">
<![CDATA[ and "region_id" = #{condition.region_id.EQUAL_TO}]]>
</if>
<if test="condition.region_id!=null and condition.region_id.NOT_EQUAL_TO!=null">
<![CDATA[ and "region_id" <> #{condition.region_id.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.region_id!=null and condition.region_id.MORE_THAN!=null">
<![CDATA[ and "region_id" > #{condition.region_id.MORE_THAN}]]>
</if>
<if test="condition.region_id!=null and condition.region_id.LESS_THAN!=null">
<![CDATA[ and "region_id" < #{condition.region_id.LESS_THAN} ]]>
</if>
<if test="condition.region_id!=null and condition.region_id.IN!=null">
and "region_id" in
<foreach collection="condition.region_id.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.region_id!=null and condition.region_id.NOT_IN!=null">
and "region_id" not in
<foreach collection="condition.region_id.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.address!=null and condition.address.EQUAL_TO!=null">
<![CDATA[ and "address" = #{condition.address.EQUAL_TO} ]]>
</if>
<if test="condition.address!=null and condition.address.NOT_EQUAL_TO!=null">
<![CDATA[ and "address" <> #{condition.address.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.address!=null and condition.address.LIKE!=null">
and "address" LIKE CONCAT('%',#{condition.address.LIKE},'%')
</if>
<if test="condition.address!=null and condition.address.IN!=null">
and "address" in
<foreach collection="condition.address.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.address!=null and condition.address.NOT_IN!=null">
and "address" not in
<foreach collection="condition.address.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.member_status!=null and condition.member_status.EQUAL_TO!=null">
<![CDATA[ and "member_status" = #{condition.member_status.EQUAL_TO}]]>
</if>
<if test="condition.member_status!=null and condition.member_status.NOT_EQUAL_TO!=null">
<![CDATA[ and "member_status" <> #{condition.member_status.NOT_EQUAL_TO} ]]>
</if>
<if test="condition.member_status!=null and condition.member_status.MORE_THAN!=null">
<![CDATA[ and "member_status" > #{condition.member_status.MORE_THAN}]]>
</if>
<if test="condition.member_status!=null and condition.member_status.LESS_THAN!=null">
<![CDATA[ and "member_status" < #{condition.member_status.LESS_THAN} ]]>
</if>
<if test="condition.member_status!=null and condition.member_status.IN!=null">
and "member_status" in
<foreach collection="condition.member_status.IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.member_status!=null and condition.member_status.NOT_IN!=null">
and "member_status" not in
<foreach collection="condition.member_status.NOT_IN" index="index"
item="item" open="(" separator="," close=")">#{item}
</foreach>
</if>
<if test="condition.data_completed!=null and condition.data_completed.EQUAL_TO!=null">
<![CDATA[ and COALESCE( "data_completed",false ) = #{condition.data_completed.EQUAL_TO} ]]>
</if>
<if test="condition.data_completed!=null and condition.data_completed.NOT_EQUAL_TO!=null">
<![CDATA[ and COALESCE("data_completed",false) <> #{condition.data_completed.NOT_EQUAL_TO} ]]>
</if>
</sql>
<sql id="base_update_set_values_for_Member">
<if test="model.name!=null">"name"=#{model.name},</if>
<if test="model.email!=null">"email"=#{model.email},</if>
<if test="model.mobile!=null">"mobile"=#{model.mobile},</if>
<if test="model.password!=null">"password"=#{model.password},</if>
<if test="model.avatar!=null">"avatar"=#{model.avatar},</if>
<if test="model.regist_time!=null">"regist_time"=#{model.regist_time},</if>
<if test="model.token!=null">"token"=#{model.token},</if>
<if test="model.longitude!=null">"longitude"=#{model.longitude},</if>
<if test="model.latitude!=null">"latitude"=#{model.latitude},</if>
<if test="model.wxopenid!=null">"wxopenid"=#{model.wxopenid},</if>
<if test="model.unionid!=null">"unionid"=#{model.unionid},</if>
<if test="model.qqkey!=null">"qqkey"=#{model.qqkey},</if>
<if test="model.login_time!=null">"login_time"=#{model.login_time},</if>
<if test="model.last_login_time!=null">"last_login_time"=#{model.last_login_time},</if>
<if test="model.region_id!=null">"region_id"=#{model.region_id},</if>
<if test="model.address!=null">"address"=#{model.address},</if>
<if test="model.member_status!=null">"member_status"=#{model.member_status},</if>
<if test="model.data_completed!=null">"data_completed"=#{model.data_completed},</if>
</sql>
<sql id="base_insert_values_for_Member">
(
<trim prefix="" suffixOverrides=",">
"name",
"email",
"mobile",
"password",
"avatar",
"regist_time",
"token",
"longitude",
"latitude",
"wxopenid",
"unionid",
"qqkey",
"login_time",
"last_login_time",
"region_id",
"address",
"member_status",
"data_completed",
</trim>
)
values
(
<trim prefix="" suffixOverrides=",">
#{model.name},
#{model.email},
#{model.mobile},
#{model.password},
#{model.avatar},
#{model.regist_time},
#{model.token},
#{model.longitude},
#{model.latitude},
#{model.wxopenid},
#{model.unionid},
#{model.qqkey},
#{model.login_time},
#{model.last_login_time},
#{model.region_id},
#{model.address},
#{model.member_status},
#{model.data_completed},
</trim>
)
</sql>
<sql id="base_write_entire_values_for_Member">
(
<trim prefix="" suffixOverrides=",">
"id",
"name",
"email",
"mobile",
"password",
"avatar",
"regist_time",
"token",
"longitude",
"latitude",
"wxopenid",
"unionid",
"qqkey",
"login_time",
"last_login_time",
"region_id",
"address",
"member_status",
"data_completed",
</trim>
)
values
(
<trim prefix="" suffixOverrides=",">
#{model.id},
#{model.name},
#{model.email},
#{model.mobile},
#{model.password},
#{model.avatar},
#{model.regist_time},
#{model.token},
#{model.longitude},
#{model.latitude},
#{model.wxopenid},
#{model.unionid},
#{model.qqkey},
#{model.login_time},
#{model.last_login_time},
#{model.region_id},
#{model.address},
#{model.member_status},
#{model.data_completed},
</trim>
)
</sql>
</mapper>
MemberMapper.xml
ps:增删改查全都是用自定义工具直接生成的,然而上面的功能已经可以满80%的需求了,连条件化搜索都有,剩下的特殊需求就要人工手动进行修改。
serviceImpl及bizImpl分别是继承api子项目里面的接口,
例如:
Provider.java是入口类,在打包时候不要忘记mainclass设定是这个,
package net.w2p.MicroBase;
import com.alibaba.fastjson.JSONObject;
import net.w2p.MicroBase.searcher.account.MemberCondition;
import net.w2p.MicroBase.service.account.MemberRoleService;
import net.w2p.MicroBase.service.account.MemberService;
import net.w2p.MicroBase.vo.account.Member;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.io.IOException;
import java.util.ArrayList;
public class Provider {
public static void main(String[] args) throws IOException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
context.start();
MemberRoleService roleService=context.getBean(MemberRoleService.class);
MemberService tmpService=context.getBean(MemberService.class);
ArrayList<Member> nowMembers=tmpService.simpleSearch(new MemberCondition());
String str= JSONObject.toJSONString(nowMembers);
System.out.println(str);
// FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(currentConfgPath);
//
// System.out.println(context.getDisplayName() + ": here");
// context.start();
// MemberRoleService roleService=context.getBean(MemberRoleService.class);
System.out.println("服务已经启动...");
System.in.read();
}
}
下面要提一下provider提供者的配置文件了,
provider.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:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
">
<import resource="classpath:conf/dubbo/MicroBase-provider4service.xml"></import>
<import resource="classpath:conf/dubbo/MicroBase-provider4biz.xml"></import>
</beans>
provider4biz.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:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
">
<!--biz复合业务逻辑层-->
<!--account 子模块 begin-->
<!--Account begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.account.AccountBiz"
ref="MicroBase.biz.AccountBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.AccountBiz"
class="net.w2p.MicroBase.bizImpl.account.AccountBizImpl"/>
<!--Account end-->
<!--Attention begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.account.AttentionBiz"
ref="MicroBase.biz.account.AttentionBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.account.AttentionBiz"
class="net.w2p.MicroBase.bizImpl.account.AttentionBizImpl"/>
<!--Attention end-->
<!--account 子模块 end-->
<!--cms 子模块 begin -->
<!--Article begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.cms.ArticleBiz"
ref="MicroBase.biz.cms.ArticleBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.cms.ArticleBiz"
class="net.w2p.MicroBase.bizImpl.cms.ArticleBizImpl"/>
<!--Article end-->
<!--cms 子模块 end -->
<!--common 子模块 begin -->
<!--CustomForm begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.common.CustomFormBiz"
ref="MicroBase.biz.common.CustomFormBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.common.CustomFormBiz"
class="net.w2p.MicroBase.bizImpl.common.CustomFormBizImpl"/>
<!--CustomForm end-->
<!--FeedBack begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.common.FeedBackBiz"
ref="MicroBase.biz.common.FeedBackBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.common.FeedBackBiz"
class="net.w2p.MicroBase.bizImpl.common.FeedBackBizImpl"/>
<!--FeedBack end-->
<!--Region begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.common.RegionBiz"
ref="MicroBase.biz.common.RegionBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.common.RegionBiz"
class="net.w2p.MicroBase.bizImpl.common.RegionBizImpl"/>
<!--Region end-->
<!--Tag begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.common.TagBiz"
ref="MicroBase.biz.common.TagBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.common.TagBiz"
class="net.w2p.MicroBase.bizImpl.common.TagBizImpl"/>
<!--Tag end-->
<!--Ticket begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.common.TicketBiz"
ref="MicroBase.biz.common.TicketBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.common.TicketBiz"
class="net.w2p.MicroBase.bizImpl.common.TicketBizImpl"/>
<!--Ticket end-->
<!--VerifyCode begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.common.VerifyCodeBiz"
ref="MicroBase.biz.common.VerifyCodeBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.common.VerifyCodeBiz"
class="net.w2p.MicroBase.bizImpl.common.VerifyCodeBizImpl"/>
<!--VerifyCode end-->
<!--common 子模块 end -->
<!--information 子模块 begin -->
<!--SiteMail begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.information.SiteMailBiz"
ref="MicroBase.biz.information.SiteMailBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.information.SiteMailBiz"
class="net.w2p.MicroBase.bizImpl.information.SiteMailBizImpl"/>
<!--SiteMail end-->
<!--SysMsg begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.information.SysMsgBiz"
ref="MicroBase.biz.information.SysMsgBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.information.SysMsgBiz"
class="net.w2p.MicroBase.bizImpl.information.SysMsgBizImpl"/>
<!--SysMsg end-->
<!--information 子模块 end -->
<!--plugins 子模块 begin -->
<!--Email begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.plugins.EmailBiz"
ref="MicroBase.biz.plugins.EmailBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.plugins.EmailBiz"
class="net.w2p.MicroBase.bizImpl.plugins.EmailBizImpl"/>
<!--Email end-->
<!--Sms begin-->
<dubbo:service interface="net.w2p.MicroBase.biz.plugins.SmsBiz"
ref="MicroBase.biz.plugins.SmsBiz"
protocol="dubbo" />
<bean id="MicroBase.biz.plugins.SmsBiz"
class="net.w2p.MicroBase.bizImpl.plugins.SmsBizImpl"/>
<!--Sms end-->
<!--plugins 子模块 end -->
</beans>
provider4service.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:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
">
<!--service 服务层的对外接口-->
<!--account 子模块 begin-->
<!--MemberRole begin-->
<dubbo:service interface="net.w2p.MicroBase.service.account.MemberRoleService"
ref="MicroBase.account.MemberRoleService"
protocol="dubbo" />
<bean id="MicroBase.account.MemberRoleService"
class="net.w2p.MicroBase.serviceImpl.account.MemberRoleServiceImpl"/>
<!--MemberRole end-->
<!--Member begin-->
<dubbo:service interface="net.w2p.MicroBase.service.account.MemberService"
ref="MicroBase.account.MemberService"
protocol="dubbo" />
<bean id="MicroBase.account.MemberService"
class="net.w2p.MicroBase.serviceImpl.account.MemberServiceImpl"/>
<!--Member end-->
<!--CorpMember begin-->
<dubbo:service interface="net.w2p.MicroBase.service.account.CorpMemberService"
ref="MicroBase.account.CorpMemberService"
protocol="dubbo" />
<bean id="MicroBase.account.CorpMemberService"
class="net.w2p.MicroBase.serviceImpl.account.CorpMemberServiceImpl"/>
<!--CorpMember end-->
<!--Corporation begin-->
<dubbo:service interface="net.w2p.MicroBase.service.account.CorporationService"
ref="MicroBase.account.CorporationService"
protocol="dubbo" />
<bean id="MicroBase.account.CorporationService"
class="net.w2p.MicroBase.serviceImpl.account.CorporationServiceImpl"/>
<!--Corporation end-->
<!--MemberAttention begin-->
<dubbo:service interface="net.w2p.MicroBase.service.account.MemberAttentionService"
ref="MicroBase.account.MemberAttentionService"
protocol="dubbo" />
<bean id="MicroBase.account.MemberAttentionService"
class="net.w2p.MicroBase.serviceImpl.account.MemberAttentionServiceImpl"/>
<!--MemberAttention end-->
<!--account 子模块 end-->
<!--cms 子模块 begin -->
<!--ArticleCategory begin-->
<dubbo:service interface="net.w2p.MicroBase.service.cms.ArticleCategoryService"
ref="MicroBase.cms.ArticleCategoryService"
protocol="dubbo" />
<bean id="MicroBase.cms.ArticleCategoryService"
class="net.w2p.MicroBase.serviceImpl.cms.ArticleCategoryServiceImpl"/>
<!--ArticleCategory end-->
<!--Article begin-->
<dubbo:service interface="net.w2p.MicroBase.service.cms.ArticleService"
ref="MicroBase.cms.ArticleService"
protocol="dubbo" />
<bean id="MicroBase.cms.ArticleService"
class="net.w2p.MicroBase.serviceImpl.cms.ArticleServiceImpl"/>
<!--Article end-->
<!--cms 子模块 end -->
<!--common 子模块 begin -->
<!--AdsCategory begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.AdsCategoryService"
ref="MicroBase.common.AdsCategoryService"
protocol="dubbo" />
<bean id="MicroBase.common.AdsCategoryService"
class="net.w2p.MicroBase.serviceImpl.common.AdsCategoryServiceImpl"/>
<!--AdsCategory end-->
<!--Advertisement begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.AdvertisementService"
ref="MicroBase.common.AdvertisementService"
protocol="dubbo" />
<bean id="MicroBase.common.AdvertisementService"
class="net.w2p.MicroBase.serviceImpl.common.AdvertisementServiceImpl"/>
<!--Advertisement end-->
<!--CommonFile begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.CommonFileService"
ref="MicroBase.common.CommonFileService"
protocol="dubbo" />
<bean id="MicroBase.common.CommonFileService"
class="net.w2p.MicroBase.serviceImpl.common.CommonFileServiceImpl"/>
<!--CommonFile end-->
<!--CommonImage begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.CommonImageService"
ref="MicroBase.common.CommonImageService"
protocol="dubbo" />
<bean id="MicroBase.common.CommonImageService"
class="net.w2p.MicroBase.serviceImpl.common.CommonImageServiceImpl"/>
<!--CommonImage end-->
<!--Config begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.ConfigService"
ref="MicroBase.common.ConfigService"
protocol="dubbo" />
<bean id="MicroBase.common.ConfigService"
class="net.w2p.MicroBase.serviceImpl.common.ConfigServiceImpl"/>
<!--Config end-->
<!--ConfigSet begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.ConfigSetService"
ref="MicroBase.common.ConfigSetService"
protocol="dubbo" />
<bean id="MicroBase.common.ConfigSetService"
class="net.w2p.MicroBase.serviceImpl.common.ConfigSetServiceImpl"/>
<!--ConfigSet end-->
<!--DictCate begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.DictCateService"
ref="MicroBase.common.DictCateService"
protocol="dubbo" />
<bean id="MicroBase.common.DictCateService"
class="net.w2p.MicroBase.serviceImpl.common.DictCateServiceImpl"/>
<!--DictCate end-->
<!--DictItem begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.DictItemService"
ref="MicroBase.common.DictItemService"
protocol="dubbo" />
<bean id="MicroBase.common.DictItemService"
class="net.w2p.MicroBase.serviceImpl.common.DictItemServiceImpl"/>
<!--DictItem end-->
<!--FeedBack begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.FeedBackService"
ref="MicroBase.common.FeedBackService"
protocol="dubbo" />
<bean id="MicroBase.common.FeedBackService"
class="net.w2p.MicroBase.serviceImpl.common.FeedBackServiceImpl"/>
<!--FeedBack end-->
<!--FieldOption begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.FieldOptionService"
ref="MicroBase.common.FieldOptionService"
protocol="dubbo" />
<bean id="MicroBase.common.FieldOptionService"
class="net.w2p.MicroBase.serviceImpl.common.FieldOptionServiceImpl"/>
<!--FieldOption end-->
<!--FormField begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.FormFieldService"
ref="MicroBase.common.FormFieldService"
protocol="dubbo" />
<bean id="MicroBase.common.FormFieldService"
class="net.w2p.MicroBase.serviceImpl.common.FormFieldServiceImpl"/>
<!--FormField end-->
<!--FormResult begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.FormResultService"
ref="MicroBase.common.FormResultService"
protocol="dubbo" />
<bean id="MicroBase.common.FormResultService"
class="net.w2p.MicroBase.serviceImpl.common.FormResultServiceImpl"/>
<!--FormResult end-->
<!--Form begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.FormService"
ref="MicroBase.common.FormService"
protocol="dubbo" />
<bean id="MicroBase.common.FormService"
class="net.w2p.MicroBase.serviceImpl.common.FormServiceImpl"/>
<!--Form end-->
<!--Region begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.RegionService"
ref="MicroBase.common.RegionService"
protocol="dubbo" />
<bean id="MicroBase.common.RegionService"
class="net.w2p.MicroBase.serviceImpl.common.RegionServiceImpl"/>
<!--Region end-->
<!--ResultItem begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.ResultItemService"
ref="MicroBase.common.ResultItemService"
protocol="dubbo" />
<bean id="MicroBase.common.ResultItemService"
class="net.w2p.MicroBase.serviceImpl.common.ResultItemServiceImpl"/>
<!--ResultItem end-->
<!--Tag begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.TagService"
ref="MicroBase.common.TagService"
protocol="dubbo" />
<bean id="MicroBase.common.TagService"
class="net.w2p.MicroBase.serviceImpl.common.TagServiceImpl"/>
<!--Tag end-->
<!--Ticket begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.TicketService"
ref="MicroBase.common.TicketService"
protocol="dubbo" />
<bean id="MicroBase.common.TicketService"
class="net.w2p.MicroBase.serviceImpl.common.TicketServiceImpl"/>
<!--Ticket end-->
<!--TicketCollection begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.TicketCollectionService"
ref="MicroBase.common.TicketCollectionService"
protocol="dubbo" />
<bean id="MicroBase.common.TicketCollectionService"
class="net.w2p.MicroBase.serviceImpl.common.TicketCollectionServiceImpl"/>
<!--TicketCollection end-->
<!--VerifyCode begin-->
<dubbo:service interface="net.w2p.MicroBase.service.common.VerifyCodeService"
ref="MicroBase.common.VerifyCodeService"
protocol="dubbo" />
<bean id="MicroBase.common.VerifyCodeService"
class="net.w2p.MicroBase.serviceImpl.common.VerifyCodeServiceImpl"/>
<!--VerifyCode end-->
<!--common 子模块 end -->
<!--information 子模块 begin -->
<!--MsgState begin-->
<dubbo:service interface="net.w2p.MicroBase.service.information.MsgStateService"
ref="MicroBase.information.MsgStateService"
protocol="dubbo" />
<bean id="MicroBase.information.MsgStateService"
class="net.w2p.MicroBase.serviceImpl.information.MsgStateServiceImpl"/>
<!--MsgState end-->
<!--SiteMail begin-->
<dubbo:service interface="net.w2p.MicroBase.service.information.SiteMailService"
ref="MicroBase.information.SiteMailService"
protocol="dubbo" />
<bean id="MicroBase.information.SiteMailService"
class="net.w2p.MicroBase.serviceImpl.information.SiteMailServiceImpl"/>
<!--SiteMail end-->
<!--SiteMailState begin-->
<dubbo:service interface="net.w2p.MicroBase.service.information.SiteMailStateService"
ref="MicroBase.information.SiteMailStateService"
protocol="dubbo" />
<bean id="MicroBase.information.SiteMailStateService"
class="net.w2p.MicroBase.serviceImpl.information.SiteMailStateServiceImpl"/>
<!--SiteMailState end-->
<!--SiteMailTo begin-->
<dubbo:service interface="net.w2p.MicroBase.service.information.SiteMailToService"
ref="MicroBase.information.SiteMailToService"
protocol="dubbo" />
<bean id="MicroBase.information.SiteMailToService"
class="net.w2p.MicroBase.serviceImpl.information.SiteMailToServiceImpl"/>
<!--SiteMailTo end-->
<!--SysMsgOwner begin-->
<dubbo:service interface="net.w2p.MicroBase.service.information.SysMsgOwnerService"
ref="MicroBase.information.SysMsgOwnerService"
protocol="dubbo" />
<bean id="MicroBase.information.SysMsgOwnerService"
class="net.w2p.MicroBase.serviceImpl.information.SysMsgOwnerServiceImpl"/>
<!--SysMsgOwner end-->
<!--SysMsg begin-->
<dubbo:service interface="net.w2p.MicroBase.service.information.SysMsgService"
ref="MicroBase.information.SysMsgService"
protocol="dubbo" />
<bean id="MicroBase.information.SysMsgService"
class="net.w2p.MicroBase.serviceImpl.information.SysMsgServiceImpl"/>
<!--SysMsg end-->
<!--information 子模块 end -->
<!--logs 子模块 begin -->
<!--EmailLog begin-->
<dubbo:service interface="net.w2p.MicroBase.service.logs.EmailLogService"
ref="MicroBase.logs.EmailLogService"
protocol="dubbo" />
<bean id="MicroBase.logs.EmailLogService"
class="net.w2p.MicroBase.serviceImpl.logs.EmailLogServiceImpl"/>
<!--EmailLog end-->
<!--SmsLog begin-->
<dubbo:service interface="net.w2p.MicroBase.service.logs.SmsLogService"
ref="MicroBase.logs.SmsLogService"
protocol="dubbo" />
<bean id="MicroBase.logs.SmsLogService"
class="net.w2p.MicroBase.serviceImpl.logs.SmsLogServiceImpl"/>
<!--SmsLog end-->
<!--logs 子模块 end -->
</beans>
好了,这些是dubbo的服务提供者配置文件,在applicationContext.xml下面这样配置即可:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
">
<beans>
<context:property-placeholder
location="classpath:conf/env/*.properties" />
<import resource="classpath:conf/spring/spring-*.xml"></import>
<import resource="classpath:provider.xml"></import>
</beans>
</beans>
下面就是最重要的pom配置文件了,这个文件决定着打包的结果,也是jenkins自动构建的一个核心文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>micro-base</artifactId>
<groupId>net.w2p</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>MicroBaseApp</artifactId>
<!--设置配置环境profile begin -->
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<package.environment>dev</package.environment>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<package.environment>test</package.environment>
</properties>
</profile>
<profile>
<id>product</id>
<properties>
<package.environment>product</package.environment>
</properties>
</profile>
</profiles>
<!--设置配置环境profile bend -->
<!--好了,是不是经常发现pom文件一加一点东西idea的编译环境就会自动变化1.5版本的jdk??加上这个强行指定编译版本就没问题了。-->
<build>
<!--真受不了每次打包出来的叫 MicroBase-SNAPSHOT-1.0.jar这种抓鸡的名字了,直接指定。。-->
<!--<finalName>${project.artifactId}-${project.version}</finalName>-->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
</compilerArgs>
</configuration>
</plugin>
<!--
打包思路说明:
1、首先,根据不同环境复制不同的配置文件出来;
2、使用maven jar plugin将当前class都打包成为一个jar文件,当然,这里还要以lib为前缀将需要使用到的地方jar包写入MF文件里面去;
3、使用assembly插件将jar等到复制过来然后统一打包成为一个tar文件,对了,这一步不要做归档就是说不要再打包jar什么的,第二步已经做了。
-->
<!--根据不同环境进行文件复制等 begin -->
<!-- 不同环境的配置文件选择 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<!-- 覆盖原有文件 -->
<overwrite>true</overwrite>
<outputDirectory>${project.build.outputDirectory}/conf/env</outputDirectory>
<!-- 也可以用下面这样的方式(指定相对url的方式指定outputDirectory) <outputDirectory>target/classes</outputDirectory> -->
<!-- 待处理的资源定义 -->
<resources>
<resource>
<!-- 指定resources插件处理哪个目录下的资源文件 -->
<directory>src/main/resources/conf/${package.environment}</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
<!--<inherited></inherited>-->
</execution>
</executions>
</plugin>
<!--根据不同环境进行文件复制等 end -->
<!-- The configuration of maven-jar-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<!-- The configuration of the plugin -->
<configuration>
<!-- Configuration of the archiver -->
<archive>
<!--
生成的jar中,不要包含pom.xml和pom.properties这两个文件
-->
<addMavenDescriptor>false</addMavenDescriptor>
<!-- Manifest specific configuration -->
<manifest>
<!--
是否要把第三方jar放到manifest的classpath中
-->
<addClasspath>true</addClasspath>
<!--
生成的manifest中classpath的前缀,因为要把第三方jar放到lib目录下,所以classpath的前缀是lib/
-->
<classpathPrefix>lib/</classpathPrefix>
<!--
应用的main class
-->
<mainClass>net.w2p.MicroBase.Provider</mainClass>
</manifest>
</archive>
<!--
过滤掉不希望包含在jar中的文件
-->
<excludes>
<exclude>${project.basedir}/xml/*</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
<!--<descriptor>src/main/resources/assembly.xml</descriptor>-->
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<!--指定资源过滤 begin -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<!--指定资源过滤 end -->
</build>
<dependencies>
<!--基础类库-->
<dependency>
<!--Group net.funfunle-->
<!--Name baselib-->
<groupId>net.funfunle</groupId>
<artifactId>baselib</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<!--基础类库 end-->
<!--app项目对应api项目 begin -->
<dependency>
<groupId>net.w2p</groupId>
<artifactId>MicroBaseApi</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!--app项目对应api项目 end-->
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.2</version>
</dependency>
<!-- 神兽一般的提醒!!!!:不要用maven上面的postgresql驱动,因为是不行的!!!要用官网下载下来的!!! -->
<!--<!– https://mvnrepository.com/artifact/postgresql/postgresql –>-->
<!--<dependency>-->
<!--<groupId>postgresql</groupId>-->
<!--<artifactId>postgresql</artifactId>-->
<!--<version>9.1-901-1.jdbc4</version>-->
<!--</dependency>-->
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>
<!-- Servlet web -->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!--dubbo begin-->
<!-- dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.6.2</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.10</version>
</dependency>
<!--dubbo end-->
<!--阿里云及阿里大于 begin -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.2.8</version>
<!--注:如提示报错,先升级基础包版,无法解决可联系技术支持-->
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.1.0</version>
</dependency>
<!--阿里云及阿里大于 end -->
<!-- https://mvnrepository.com/artifact/org.apache.curator/curator-framework -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.0.1</version>
</dependency>
<!--apache commons 类库 begin -->
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-httpclient/commons-httpclient -->
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<!--apache commons 类库 end -->
</dependencies>
</project>
打包及执行结果
一旦进行package以后,
输出物如下:
看看MicroBaseApp-Build.zip的内容:
看看MicroBaseApp.jar的内容:
MF文件的第三方类库路径简直恐怖,
好了,解压到某个路径然后执行:
某些涉及到个人信息的地方大码了:
服务提供者+dubbo+spring+maven打包成功,执行成功
话说,最复杂的不是自动化,maven打包,而是,在打包前要确立整个项目的框架,分层,配置文件摆放,配置以及调通dubbo,mybatis,spring,这些才是最难的。