forked from zq2599/blog_demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
819 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?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>customizestarter</artifactId> | ||
<groupId>com.bolingcavalry</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
<artifactId>addservice</artifactId> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.bolingcavalry</groupId> | ||
<artifactId>customizeapi</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
15 changes: 15 additions & 0 deletions
15
...er/addservice/src/main/java/com/bolingcavalry/addservice/service/impl/AddServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.bolingcavalry.addservice.service.impl; | ||
|
||
import com.bolingcavalry.api.service.AddService; | ||
|
||
/** | ||
* @author wilzhao | ||
* @description 加法服务的实现 | ||
* @email [email protected] | ||
* @time 2018/10/13 10:59 | ||
*/ | ||
public class AddServiceImpl implements AddService { | ||
public int add(int a, int b) { | ||
return a + b; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?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>customizestarter</artifactId> | ||
<groupId>com.bolingcavalry</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>customizeapi</artifactId> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
...izestarter/customizeapi/src/main/java/com/bolingcavalry/api/exception/MinusException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.bolingcavalry.api.exception; | ||
|
||
/** | ||
* @author wilzhao | ||
* @description 执行减法服务时抛出的异常 | ||
* @email [email protected] | ||
* @time 2018/10/13 14:20 | ||
*/ | ||
public class MinusException extends Exception{ | ||
public MinusException(String message) { | ||
super(message); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
customizestarter/customizeapi/src/main/java/com/bolingcavalry/api/service/AddService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.bolingcavalry.api.service; | ||
|
||
/** | ||
* @author wilzhao | ||
* @description 加法服务对应的接口 | ||
* @email [email protected] | ||
* @time 2018/10/13 10:07 | ||
*/ | ||
public interface AddService { | ||
|
||
/** | ||
* 普通加法 | ||
* @param a | ||
* @param b | ||
* @return | ||
*/ | ||
int add(int a, int b); | ||
} |
19 changes: 19 additions & 0 deletions
19
customizestarter/customizeapi/src/main/java/com/bolingcavalry/api/service/MinusService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.bolingcavalry.api.service; | ||
|
||
import com.bolingcavalry.api.exception.MinusException; | ||
|
||
/** | ||
* @author wilzhao | ||
* @description 减法服务 | ||
* @email [email protected] | ||
* @time 2018/10/13 12:07 | ||
*/ | ||
public interface MinusService { | ||
/** | ||
* 普通减法 | ||
* @param minuend 减数 | ||
* @param subtraction 被减数 | ||
* @return 差 | ||
*/ | ||
int minus(int minuend, int subtraction) throws MinusException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?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>customizestarter</artifactId> | ||
<groupId>com.bolingcavalry</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
<artifactId>customizeservicestarter</artifactId> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-autoconfigure</artifactId> | ||
<!--仅编译时才需要--> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.bolingcavalry</groupId> | ||
<artifactId>customizeapi</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.bolingcavalry</groupId> | ||
<artifactId>addservice</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.bolingcavalry</groupId> | ||
<artifactId>minusservice</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
</project> |
53 changes: 53 additions & 0 deletions
53
...arter/src/main/java/com/bolingcavalry/customizeservicestarter/CustomizeConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.bolingcavalry.customizeservicestarter; | ||
|
||
import com.bolingcavalry.addservice.service.impl.AddServiceImpl; | ||
import com.bolingcavalry.api.service.AddService; | ||
import com.bolingcavalry.api.service.MinusService; | ||
import com.bolingcavalry.minusservice.service.impl.MinusServiceNotSupportNegativeImpl; | ||
import com.bolingcavalry.minusservice.service.impl.MinusServiceSupportNegativeImpl; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* @author wilzhao | ||
* @description 一句话介绍 | ||
* @email [email protected] | ||
* @time 2018/10/13 14:36 | ||
*/ | ||
@Configuration | ||
public class CustomizeConfiguration { | ||
|
||
@Bean | ||
public AddService getAddService(){ | ||
System.out.println("create addService"); | ||
return new AddServiceImpl(); | ||
} | ||
|
||
/** | ||
* 如果配置了com.bolingcavalry.supportnegative=true, | ||
* 就实例化MinusServiceSupportNegativeImpl | ||
* @return | ||
*/ | ||
@Bean | ||
@ConditionalOnProperty(prefix="com.bolingcavalry",name = "supportnegative", havingValue = "true") | ||
public MinusService getSupportMinusService(){ | ||
System.out.println("create minusService support minus"); | ||
return new MinusServiceSupportNegativeImpl(); | ||
} | ||
|
||
/** | ||
* 如果没有配置com.bolingcavalry.supportnegative=true, | ||
* 就不会实例化MinusServiceSupportNegativeImpl, | ||
* 这里的条件是如果没有MinusService类型的bean,就在此实例化一个 | ||
* @return | ||
*/ | ||
@Bean | ||
@ConditionalOnMissingBean(MinusService.class) | ||
public MinusService getNotSupportMinusService(){ | ||
System.out.println("create minusService not support minus"); | ||
return new MinusServiceNotSupportNegativeImpl(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
customizestarter/customizeservicestarter/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.bolingcavalry.customizeservicestarter.CustomizeConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?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>customizestarter</artifactId> | ||
<groupId>com.bolingcavalry</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>minusservice</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.bolingcavalry</groupId> | ||
<artifactId>customizeapi</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
28 changes: 28 additions & 0 deletions
28
.../java/com/bolingcavalry/minusservice/service/impl/MinusServiceNotSupportNegativeImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.bolingcavalry.minusservice.service.impl; | ||
|
||
import com.bolingcavalry.api.exception.MinusException; | ||
import com.bolingcavalry.api.service.MinusService; | ||
|
||
/** | ||
* @author wilzhao | ||
* @description 减法服务的实现,不支持负数 | ||
* @email [email protected] | ||
* @time 2018/10/13 14:24 | ||
*/ | ||
public class MinusServiceNotSupportNegativeImpl implements MinusService { | ||
|
||
/** | ||
* 减法运算,不支持负数结果,如果被减数小于减数,就跑出MinusException | ||
* @param minuend 被减数 | ||
* @param subtraction 减数 | ||
* @return | ||
* @throws MinusException | ||
*/ | ||
public int minus(int minuend, int subtraction) throws MinusException { | ||
if(subtraction>minuend){ | ||
throw new MinusException("not support negative!"); | ||
} | ||
|
||
return minuend-subtraction; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ain/java/com/bolingcavalry/minusservice/service/impl/MinusServiceSupportNegativeImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.bolingcavalry.minusservice.service.impl; | ||
|
||
import com.bolingcavalry.api.exception.MinusException; | ||
import com.bolingcavalry.api.service.MinusService; | ||
|
||
/** | ||
* @author wilzhao | ||
* @description 支持负数结果的减法服务 | ||
* @email [email protected] | ||
* @time 2018/10/13 14:30 | ||
*/ | ||
public class MinusServiceSupportNegativeImpl implements MinusService { | ||
|
||
/** | ||
* 减法实现,支持负数 | ||
* @param minuend 减数 | ||
* @param subtraction 被减数 | ||
* @return | ||
* @throws MinusException | ||
*/ | ||
public int minus(int minuend, int subtraction) throws MinusException { | ||
return minuend - subtraction; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.bolingcavalry</groupId> | ||
<artifactId>customizestarter</artifactId> | ||
<packaging>pom</packaging> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>1.5.9.RELEASE</version> | ||
<relativePath/> | ||
</parent> | ||
|
||
<modules> | ||
<!--加法服务--> | ||
<module>addservice</module> | ||
<!--减法服务--> | ||
<module>minusservice</module> | ||
<!--接口和异常定义--> | ||
<module>customizeapi</module> | ||
<!--启动器--> | ||
<module>customizeservicestarter</module> | ||
</modules> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/build/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip |
Oops, something went wrong.