Skip to content

Commit

Permalink
提交 lombok 与 maven 隔离!
Browse files Browse the repository at this point in the history
  • Loading branch information
qiurunze123 committed Oct 27, 2018
1 parent 55fbc8d commit 87c7ac9
Show file tree
Hide file tree
Showing 41 changed files with 640 additions and 312 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ redis的数量不是库存,他的作用仅仅只是为了阻挡多余的请求

### <font color=#0099ff size=3 >15.mybatis如何使用注解与xml配置?</font><br>
本文使用的是注解方法开发所以不做过多解释<br>
下面仔细讲解以下如何详细使用xml开发<br>
下面仔细讲解以下如何详细使用xml开发在目录里面有一个与本文无挂的类似于微信自动回复的功能br>
里面有mybatis的全部解析和用法,大家可以简单的当做一个demo来使用<br>
12 changes: 10 additions & 2 deletions miaosha.iml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.alibaba:dubbo:2.5.3" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
<orderEntry type="library" name="Maven: org.jboss.netty:netty:3.2.5.Final" level="project" />
<orderEntry type="library" name="Maven: org.apache.zookeeper:zookeeper:3.4.6" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: jline:jline:0.9.94" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty:3.7.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.8.RELEASE" level="project" />
Expand Down Expand Up @@ -54,9 +63,7 @@
<orderEntry type="library" name="Maven: org.thymeleaf:thymeleaf-spring4:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.thymeleaf:thymeleaf:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ognl:ognl:3.0.8" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
<orderEntry type="library" name="Maven: org.unbescape:unbescape:1.1.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.groovy:groovy:2.4.12" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1" level="project" />
Expand Down Expand Up @@ -86,5 +93,6 @@
<orderEntry type="library" name="Maven: org.springframework.retry:spring-retry:1.2.1.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.amqp:spring-amqp:1.7.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.3.12.RELEASE" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.2" level="project" />
</component>
</module>
99 changes: 99 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,33 @@
</properties>

<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>

</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down Expand Up @@ -96,6 +122,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!--lombook引用-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.2</version>
<scope>provided</scope>
</dependency>

</dependencies>

<build>
Expand All @@ -105,6 +139,23 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.2.RELEASE</version>
<configuration>
<mainClass>com.geekq.miaosha.GeekQMainApplication</mainClass><!--springboot启动类目录-->
</configuration>
<executions>
<execution>
<goals> <!--创建一个自动可执行的jar或war文件 -->
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
<resources>
<resource>
Expand All @@ -113,7 +164,55 @@
<include>**/*.xml</include>
</includes>
</resource>

<resource> <!--配置文件路径 -->
<directory>src/main/resources</directory> <!--这里对应项目存放配置文件的目录--> <!--开启filtering功能 -->
<filtering>true</filtering>
<excludes>
<exclude>application.properties</exclude>
<exclude>application-dev.properties</exclude>
<exclude>application-prod.properties</exclude>
<exclude>application-test.properties</exclude>
</excludes>
</resource>

<resource> <!--配置文件路径 -->
<directory>src/main/resources</directory> <!--这里对应项目存放配置文件的目录--> <!--开启filtering功能 -->
<filtering>true</filtering>
<includes>
<include>application-${activatedProperties}.properties</include>
<include>application.properties</include>
</includes>
</resource>



</resources>


</build>

<profiles>
<profile>
<id>dev</id>
<properties> <!-- 环境标识,需要与配置文件的名称相对应 -->
<activatedProperties>dev</activatedProperties>
</properties>
<activation> <!-- 默认环境 -->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<activatedProperties>test</activatedProperties>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<activatedProperties>prod</activatedProperties>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class GeekQMainApplication {
public class GeekQMainApplication {

public static void main(String[] args) throws Exception {
SpringApplication.run(GeekQMainApplication.class, args);
SpringApplication.run(GeekQMainApplication.class, args);
}


Expand Down
76 changes: 59 additions & 17 deletions src/main/java/com/geekq/miaosha/Test.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,72 @@
package com.geekq.miaosha;

import com.geekq.miaosha.domain.MiaoshaUser;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

/**
* mybatis xml 写法的配置测试类
*/
public class Test {
public static void main(String[] args) throws IOException {
public static List<Double> list = new ArrayList<Double>();

//读取配置文件
Reader reader = Resources.getResourceAsReader("config.xml");
SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(reader);
public static void main(String[] args) {
double[] keys = {1, 2,3};
System.err.println(getNum(keys, 5));


SqlSession session = sessionFactory.openSession();
// 举例:3 个元素:a, b, c。所以有2 ^ 3 = 8 个组合结果:所以i = 0, 1, 2,....7.对应应输出 a, b, ab, c...abc(注意a表示001,不是100.)
//
// 将i变成2进制:
// i = 1 = 001
//   i = 2 = 010
// i = 3 = 011
//
//    (1) j = 0 (1) j = 0 (1) j = 0
//   移1位:1 << j == 001 1 << j == 001 1 << j == 001
//   和i = 001 相与,两个位都为1,返回1 与i无相同位 和i = 001 相与,两个位都为1,返回1
//   输出:a 输出a
//
// (2) j = 1 (2) j = 1 (2) j = 1
// 再移一位:1 << j == 010 1 << j == 010   1 << j == 010
// 与i = 001 相与。无相同1 和i相与,两个位都为1,返回1 和i相与,两个位都为1,返回1
// 输出b 输出b
//
// (3) j = 2 3)j = 2 (3) j = 2
// 移一位 1 << j == 100 1 << j == 100
// 与i无相同位 与i无相同位 与i无相同位
//
// 所以i = 001, 只输出a.所以i = 010, 只输出b.所以011,输出ab
//
// *************************************
// *可见上面每一个数字i, 只会判断判断3次,因为只需要移三次位,二进制就遍历完了

String statement = "com.geekq.miaosha.dao.UserMapper.getMiaoShaUserById" ;
MiaoshaUser user = session.selectOne(statement,"18612766134");
}

System.out.println(user.toString());
static List<Double> getNum(double[] keys, double kill) {
int n = keys.length;//数字长度
System.out.println(n);
int nbit = 1 << n; // 8
System.out.println(nbit);
double in;
List<Double> list = new ArrayList<Double>();
for (int i = 0; i < nbit; i++) {
System.out.println("nbit======="+i);
in = 0;
list.clear();
for (int j = 0; j < n; j++) {
System.out.println("j======"+j);
int tmp = 1 << j; // 由0到n右移位
System.out.println("tmp===="+tmp);
if ((tmp & i) != 0) { // 与运算,同为1时才会是1
System.out.println("keys[j]=========="+keys[j]);
in += keys[j];
list.add(keys[j]);
}
}
if (in == kill){
return list;
}
}
return list;
}
}
}
51 changes: 9 additions & 42 deletions src/main/java/com/geekq/miaosha/domain/Goods.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package com.geekq.miaosha.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class Goods {
private Long id;
private String goodsName;
Expand All @@ -8,46 +17,4 @@ public class Goods {
private String goodsDetail;
private Double goodsPrice;
private Integer goodsStock;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getGoodsTitle() {
return goodsTitle;
}
public void setGoodsTitle(String goodsTitle) {
this.goodsTitle = goodsTitle;
}
public String getGoodsImg() {
return goodsImg;
}
public void setGoodsImg(String goodsImg) {
this.goodsImg = goodsImg;
}
public String getGoodsDetail() {
return goodsDetail;
}
public void setGoodsDetail(String goodsDetail) {
this.goodsDetail = goodsDetail;
}
public Double getGoodsPrice() {
return goodsPrice;
}
public void setGoodsPrice(Double goodsPrice) {
this.goodsPrice = goodsPrice;
}
public Integer getGoodsStock() {
return goodsStock;
}
public void setGoodsStock(Integer goodsStock) {
this.goodsStock = goodsStock;
}
}
39 changes: 9 additions & 30 deletions src/main/java/com/geekq/miaosha/domain/MiaoshaGoods.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,20 @@
package com.geekq.miaosha.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Date;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class MiaoshaGoods {
private Long id;
private Long goodsId;
private Integer stockCount;
private Date startDate;
private Date endDate;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getGoodsId() {
return goodsId;
}
public void setGoodsId(Long goodsId) {
this.goodsId = goodsId;
}
public Integer getStockCount() {
return stockCount;
}
public void setStockCount(Integer stockCount) {
this.stockCount = stockCount;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
}
Loading

0 comments on commit 87c7ac9

Please sign in to comment.