Skip to content

Commit

Permalink
Merge ea67a75 into 6f66e26
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengyangyong committed Apr 12, 2018
2 parents 6f66e26 + ea67a75 commit b546053
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 1 deletion.
7 changes: 6 additions & 1 deletion archetypes/README.md
Expand Up @@ -5,9 +5,14 @@ From http://maven.apache.org/guides/introduction/introduction-to-archetypes.html
>In short, Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made. The name fits as we are trying to provide a system that provides a consistent means of generating Maven projects. Archetype will help authors create Maven project templates for users, and provides users with the means to generate parameterized versions of those project templates.
### What we provide
1. business-service-jaxrs
1. business-service-jaxrs

Archetype for create a common microservice using jaxrs provider.

2. business-service-spring-boot-starter

Archetype for create a common microservice using spring-boot-starter provider.

more coming soon..

### How to build these archetypes
Expand Down
Expand Up @@ -24,6 +24,7 @@ public class HelloConsumer {
private final RestTemplate restTemplate = RestTemplateBuilder.create();

public void invokeHello(){
//service url is : cse://serviceName/operation
restTemplate.getForObject("cse://business-service/hello", String.class);
}

Expand Down
18 changes: 18 additions & 0 deletions archetypes/business-service-spring-boot-starter/README.md
@@ -0,0 +1,18 @@
## Welcome to use ServiceComb Java Chassis
This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-spring-boot-starter-archetype*, it use **spring-boot-starter-provider** to develop service endpoint.

### More works can be done further:
1. Modify "HelloEndpoint", add your business service logic, or create some new endpoints to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/use-servicecomb-in-spring-boot/
2. Modify "microservice.yaml", change APPLICATION_ID, service_description.name, version, and service center address, endpoints publish address etc. More details can be found : http://servicecomb.incubator.apache.org/users/service-definition/

### Package your service
Under project(module) root folder, run
```bash
mvn package
```
Then you can get executable jar in target/bin folder:
- xxxxxx-{version}-exec.jar
```bash
java -jar xxxxxx-{version}-exec.jar
```
*Notice: If you need to modify config setting in "microservice.yaml" like service center address but don't want repackage the executable jar, **you can direct place a new "microservice.yaml" file in same folder, then settings will be overridden.***
93 changes: 93 additions & 0 deletions archetypes/business-service-spring-boot-starter/pom.xml
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<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">
<groupId>org.apache.servicecomb.archetypes</groupId>
<artifactId>business-service-spring-boot-starter</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>1.0.0-m2-SNAPSHOT</version>

<properties>
<java-chassis.version>1.0.0-m2-SNAPSHOT</java-chassis.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>java-chassis-dependencies</artifactId>
<version>${java-chassis.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>spring-boot-starter-provider</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
</dependencies>

<!--for package and deploy-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.5.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/bin</outputDirectory>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.servicecomb.archetypes;

import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableServiceComb
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.servicecomb.archetypes;

import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
import org.springframework.web.client.RestTemplate;

public class HelloConsumer {
private final RestTemplate restTemplate = RestTemplateBuilder.create();

public void invokeHello() {
//service url is : cse://serviceName/operation
restTemplate.getForObject("cse://business-service/hello", String.class);
}
}
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.servicecomb.archetypes;

import org.apache.servicecomb.provider.rest.common.RestSchema;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@RestSchema(schemaId = "helloEndpoint")
@RequestMapping(path = "/")
public class HelloEndpoint {

@GetMapping(path = "/hello")
public String hello() {
return "Hello World!";
}
}
@@ -0,0 +1,43 @@
## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------

#More details can be found :
# 1.http://servicecomb.incubator.apache.org/users/service-definition/
# 2.http://servicecomb.incubator.apache.org/users/service-configurations/
# 3.http://servicecomb.incubator.apache.org/users/communicate-protocol/

#Indicates an application name
APPLICATION_ID: business
service_description:
#Indicates a microservice name
#The microservice name should be unique within an application.
#The name can contain digits, uppercase and lowercase letters, hyphens(-), underscores(_), and periods(.); and can neither start nor end with punctuations.
#The naming rule is as follows: ^[a-zA-Z0-9]+$|^[a-zA-Z0-9][a-zA-Z0-9_-.]*[a-zA-Z0-9]$.
name: business-service
#Indicates a service version
version: 1.0.0
cse:
service:
#Specifies the service center IP address.
registry:
address: http://127.0.0.1:30100
#Specifies the rest transport listening IP address.
rest:
address: 0.0.0.0:8080
#Specifies the highway transport listening IP address.
highway:
address: 0.0.0.0:7070

0 comments on commit b546053

Please sign in to comment.