leyou-item-interface
pom.xml
pojo
- Boolean:注意isParent生成的getter和setter方法需要手动加上Is
package com.leyou.item.pojo;
import lombok.Data;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name="tb_category")
@Data
public class Category {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
public String name;
private Long parentId;
private Boolean isParent;
public Integer sort;
public Boolean getIsParent() {
return isParent;
}
public void setIsParent(Boolean parent) {
isParent = parent;
}
}
leyou-item-service
- 新建接口item.mapper.CategoryMaper
package com.leyou.item.mapper;
import com.leyou.item.pojo.Category;
import tk.mybatis.mapper.common.Mapper;
public interface CategoryMaper extends Mapper<Category> {
}
- 引导类
- import tk.mybatis.spring.annotation.MapperScan;
- @MapperScan(“com.leyou.item.mapper”)
package com.leyou;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import tk.mybatis.spring.annotation.MapperScan;
@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("com.leyou.item.mapper")
public class LeyouItemApplication {
public static void main(String[] args) {
SpringApplication.run(LeyouItemApplication.class);
}
}