pom.xml依赖
org.springframework.data
ressort-data-solr
1.5.5.RELEASE
org.springframework
ressort test
4.2.4.RELEASE
junit
junit
4,9
applicationContext-solr.xml classe de contenu
<? Xml version = "1.0" encoding = "UTF-8"?>
<Solr: id solr-server = url « solrServer » = « http://192.168.200.128:8080/solr » />
<!-- solr模板,使用solr模板可对索引库进行CRUD的操作 -->
<bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">
<constructor-arg ref="solrServer" />
</bean>
entité de données de classe
package com.offcn.core.pojo;
importation org.apache.solr.client.solrj.beans.Field;
importation java.io.Serializable;
importation java.math.BigDecimal;
import java.util.Date;
public class {article implémente Serializable
/**
* 商品id,同时也是商品编号
*/
@Field
private Long id;
/**
* 商品标题
*/
@Field("item_title")
private String title;
/**
* 商品卖点
*/
private String sellPoint;
/**
* 商品价格,单位为:元
*/
@Field("item_price")
private BigDecimal price;
private Integer stockCount;
/**
* 库存数量
*/
private Integer num;
/**
* 商品条形码
*/
private String barcode;
/**
* 商品图片
*/
@Field("item_image")
private String image;
/**
* 所属类目,叶子类目
*/
private Long categoryid;
/**
* 商品状态,1-正常,2-下架,3-删除
*/
private String status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
private String itemSn;
private BigDecimal costPirce;
private BigDecimal marketPrice;
private String isDefault;
@Field("item_goodsId")
private Long goodsId;
private String sellerId;
private String cartThumbnail;
@Field("item_category")
private String category;
@Field("item_brand")
private String brand;
private String spec;
@Field("item_seler")
private String seller;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title == null ? null : title.trim();
}
public String getSellPoint() {
return sellPoint;
}
public void setSellPoint(String sellPoint) {
this.sellPoint = sellPoint == null ? null : sellPoint.trim();
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public Integer getStockCount() {
return stockCount;
}
public void setStockCount(Integer stockCount) {
this.stockCount = stockCount;
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
public String getBarcode() {
return barcode;
}
public void setBarcode(String barcode) {
this.barcode = barcode == null ? null : barcode.trim();
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image == null ? null : image.trim();
}
public Long getCategoryid() {
return categoryid;
}
public void setCategoryid(Long categoryid) {
this.categoryid = categoryid;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status == null ? null : status.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getItemSn() {
return itemSn;
}
public void setItemSn(String itemSn) {
this.itemSn = itemSn == null ? null : itemSn.trim();
}
public BigDecimal getCostPirce() {
return costPirce;
}
public void setCostPirce(BigDecimal costPirce) {
this.costPirce = costPirce;
}
public BigDecimal getMarketPrice() {
return marketPrice;
}
public void setMarketPrice(BigDecimal marketPrice) {
this.marketPrice = marketPrice;
}
public String getIsDefault() {
return isDefault;
}
public void setIsDefault(String isDefault) {
this.isDefault = isDefault == null ? null : isDefault.trim();
}
public Long getGoodsId() {
return goodsId;
}
public void setGoodsId(Long goodsId) {
this.goodsId = goodsId;
}
public String getSellerId() {
return sellerId;
}
public void setSellerId(String sellerId) {
this.sellerId = sellerId == null ? null : sellerId.trim();
}
public String getCartThumbnail() {
return cartThumbnail;
}
public void setCartThumbnail(String cartThumbnail) {
this.cartThumbnail = cartThumbnail == null ? null : cartThumbnail.trim();
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category == null ? null : category.trim();
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand == null ? null : brand.trim();
}
public String getSpec() {
return spec;
}
public void setSpec(String spec) {
this.spec = spec == null ? null : spec.trim();
}
public String getSeller() {
return seller;
}
public void setSeller(String seller) {
this.seller = seller == null ? null : seller.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", title=").append(title);
sb.append(", sellPoint=").append(sellPoint);
sb.append(", price=").append(price);
sb.append(", stockCount=").append(stockCount);
sb.append(", num=").append(num);
sb.append(", barcode=").append(barcode);
sb.append(", image=").append(image);
sb.append(", categoryid=").append(categoryid);
sb.append(", status=").append(status);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", itemSn=").append(itemSn);
sb.append(", costPirce=").append(costPirce);
sb.append(", marketPrice=").append(marketPrice);
sb.append(", isDefault=").append(isDefault);
sb.append(", goodsId=").append(goodsId);
sb.append(", sellerId=").append(sellerId);
sb.append(", cartThumbnail=").append(cartThumbnail);
sb.append(", category=").append(category);
sb.append(", brand=").append(brand);
sb.append(", spec=").append(spec);
sb.append(", seller=").append(seller);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
Item other = (Item) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
&& (this.getSellPoint() == null ? other.getSellPoint() == null : this.getSellPoint().equals(other.getSellPoint()))
&& (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()))
&& (this.getStockCount() == null ? other.getStockCount() == null : this.getStockCount().equals(other.getStockCount()))
&& (this.getNum() == null ? other.getNum() == null : this.getNum().equals(other.getNum()))
&& (this.getBarcode() == null ? other.getBarcode() == null : this.getBarcode().equals(other.getBarcode()))
&& (this.getImage() == null ? other.getImage() == null : this.getImage().equals(other.getImage()))
&& (this.getCategoryid() == null ? other.getCategoryid() == null : this.getCategoryid().equals(other.getCategoryid()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getItemSn() == null ? other.getItemSn() == null : this.getItemSn().equals(other.getItemSn()))
&& (this.getCostPirce() == null ? other.getCostPirce() == null : this.getCostPirce().equals(other.getCostPirce()))
&& (this.getMarketPrice() == null ? other.getMarketPrice() == null : this.getMarketPrice().equals(other.getMarketPrice()))
&& (this.getIsDefault() == null ? other.getIsDefault() == null : this.getIsDefault().equals(other.getIsDefault()))
&& (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
&& (this.getSellerId() == null ? other.getSellerId() == null : this.getSellerId().equals(other.getSellerId()))
&& (this.getCartThumbnail() == null ? other.getCartThumbnail() == null : this.getCartThumbnail().equals(other.getCartThumbnail()))
&& (this.getCategory() == null ? other.getCategory() == null : this.getCategory().equals(other.getCategory()))
&& (this.getBrand() == null ? other.getBrand() == null : this.getBrand().equals(other.getBrand()))
&& (this.getSpec() == null ? other.getSpec() == null : this.getSpec().equals(other.getSpec()))
&& (this.getSeller() == null ? other.getSeller() == null : this.getSeller().equals(other.getSeller()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
result = prime * result + ((getSellPoint() == null) ? 0 : getSellPoint().hashCode());
result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
result = prime * result + ((getStockCount() == null) ? 0 : getStockCount().hashCode());
result = prime * result + ((getNum() == null) ? 0 : getNum().hashCode());
result = prime * result + ((getBarcode() == null) ? 0 : getBarcode().hashCode());
result = prime * result + ((getImage() == null) ? 0 : getImage().hashCode());
result = prime * result + ((getCategoryid() == null) ? 0 : getCategoryid().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getItemSn() == null) ? 0 : getItemSn().hashCode());
result = prime * result + ((getCostPirce() == null) ? 0 : getCostPirce().hashCode());
result = prime * result + ((getMarketPrice() == null) ? 0 : getMarketPrice().hashCode());
result = prime * result + ((getIsDefault() == null) ? 0 : getIsDefault().hashCode());
result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
result = prime * result + ((getSellerId() == null) ? 0 : getSellerId().hashCode());
result = prime * result + ((getCartThumbnail() == null) ? 0 : getCartThumbnail().hashCode());
result = prime * result + ((getCategory() == null) ? 0 : getCategory().hashCode());
result = prime * result + ((getBrand() == null) ? 0 : getBrand().hashCode());
result = prime * result + ((getSpec() == null) ? 0 : getSpec().hashCode());
result = prime * result + ((getSeller() == null) ? 0 : getSeller().hashCode());
return result;
}
}