liubao68 closed pull request #682: [SCB-527] Reorganization All Archetype For Enable Auto Publish URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/682
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/archetypes/README.md b/archetypes/README.md index 8737aeaa9..a16ce0377 100644 --- a/archetypes/README.md +++ b/archetypes/README.md @@ -9,25 +9,25 @@ From http://maven.apache.org/guides/introduction/introduction-to-archetypes.html Archetype for create a common microservice using jaxrs provider. -2. business-service-spring-boot-starter +2. business-service-springmvc - Archetype for create a common microservice using spring-boot-starter provider. + Archetype for create a common microservice using springmvc provider. + +3. business-service-pojo + + Archetype for create a common microservice using pojo provider. + +4. business-service-spring-boot-starter -more coming soon.. + Archetype for create a common microservice using spring-boot-starter provider. ### How to build these archetypes We use **business-service-jaxrs** as an example : + ```bash -cd archetypes/business-service-jaxrs -mvn archetype:create-from-project -#Wait until successed, archetype will be generated at target/generated-sources/archetype -cd target/generated-sources/archetype -#Install archetype to your local maven repository +cd archetypes mvn install ``` -*Notice: The archetype ArtifactId of business-service-jaxrs is business-service-jaxrs-**archetype.*** - -We will publish these archetypes to maven center repository since 1.0.0-m2. ### How to use these archetypes to generate a project We use **business-service-jaxrs** as an example : @@ -38,7 +38,14 @@ New Project(Module) -> Maven -> Check "Create from archetype" -> Add Archetype.. New Project(Module) -> Maven -> Next -> Add Archetype... -> fill *GroupId* with value "org.apache.servicecomb.archetypes", fill *ArtifactId* with value "business-service-jaxrs-archetype", fill *Version* with current archetype version -> select this archetype that had listed, do next steps. #### Generate via command + ```bash mvn archetype:generate -DarchetypeGroupId=org.apache.servicecomb.archetypes -DarchetypeArtifactId=business-service-jaxrs-archetype -DarchetypeVersion=${archetype-version} ``` -In console Interactive mode, input your GroupId, ArtifactId and Version of new project(module), after a while the new project will be generated. \ No newline at end of file + +In console Interactive mode, input your GroupId, ArtifactId and Version of new project(module), after a while the new project will be generated. + +*Notice: We will publish these archetypes to maven center repository since 1.0.0-m2, if you would like to use an archetype from an unreleased version : * +```bash +mvn archetype:generate -DarchetypeGroupId=org.apache.servicecomb.archetypes -DarchetypeArtifactId=business-service-jaxrs-archetype -DarchetypeVersion=${archetype-version} -DarchetypeRepository=https://repository.apache.org/content/groups/snapshots-group +``` \ No newline at end of file diff --git a/archetypes/business-service-jaxrs/README.md b/archetypes/business-service-jaxrs/README.md index 43c1dac3f..8deb67bac 100644 --- a/archetypes/business-service-jaxrs/README.md +++ b/archetypes/business-service-jaxrs/README.md @@ -1,8 +1,8 @@ ## Welcome to use ServiceComb Java Chassis -This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-jaxrs-archetype*, it use **jaxrs provider** to develop service endpoint. +This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-jaxrs-archetype*, it use **jaxrs provider** to develop service producer. ### 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/develop-with-jax-rs/ +1. Modify "HelloImpl", add your business service logic, or create some new producers to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-jax-rs/ 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/ 3. Modify setting value of "mainClass" in pom.xml for package. @@ -17,4 +17,4 @@ Then you can get outputs in target folder: ```bash java -jar xxxxxx-{version}.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.*** \ No newline at end of file +*Notice: If you need to modify configurations in "microservice.yaml" like service center address but don't want repackage the executable jar, **you can directly place a new "microservice.yaml" file under the same folder, then configurations will be overridden.*** \ No newline at end of file diff --git a/archetypes/business-service-jaxrs/pom.xml b/archetypes/business-service-jaxrs/pom.xml index 00f6f5d9d..7eb6e1160 100644 --- a/archetypes/business-service-jaxrs/pom.xml +++ b/archetypes/business-service-jaxrs/pom.xml @@ -19,99 +19,43 @@ <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> + <groupId>org.apache.servicecomb</groupId> + <artifactId>archetypes</artifactId> + <version>1.0.0-m2-SNAPSHOT</version> + </parent> + <groupId>org.apache.servicecomb.archetypes</groupId> - <artifactId>business-service-jaxrs</artifactId> + <name>Java Chassis::Archetypes::JAXRS</name> + <artifactId>business-service-jaxrs-archetype</artifactId> + <packaging>maven-archetype</packaging> <modelVersion>4.0.0</modelVersion> - <version>1.0.0-m2-SNAPSHOT</version> <properties> - <java-chassis.version>1.0.0-m2-SNAPSHOT</java-chassis.version> + <maven-archetype-packaging-version>2.3</maven-archetype-packaging-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> - <!--for provider--> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>transport-rest-vertx</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>transport-highway</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>provider-jaxrs</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </dependency> - - <!--for consumer--> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>provider-springmvc</artifactId> - </dependency> - </dependencies> - - <!--for package and deploy--> <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.6</version> - <configuration> - <archive> - <manifest> - <addClasspath>true</addClasspath> - <classpathPrefix>lib/</classpathPrefix> - <!--change to your main class--> - <mainClass>${your-package}.Application</mainClass> - </manifest> - <manifestEntries> - <Class-Path>. </Class-Path> - </manifestEntries> - </archive> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>copy-dependencies</id> - <phase>package</phase> - <goals> - <goal>copy-dependencies</goal> - </goals> - <configuration> - <outputDirectory>target/lib</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - </plugin> - </plugins> + <extensions> + <extension> + <groupId>org.apache.maven.archetype</groupId> + <artifactId>archetype-packaging</artifactId> + <version>${maven-archetype-packaging-version}</version> + </extension> + </extensions> + + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + </resource> + <resource> + <directory>src/main/resources-filtered</directory> + <filtering>true</filtering> + <includes> + <include>**/archetype-metadata.xml</include> + </includes> + </resource> + </resources> </build> </project> \ No newline at end of file diff --git a/archetypes/business-service-jaxrs/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/archetypes/business-service-jaxrs/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml new file mode 100644 index 000000000..e953ae8b7 --- /dev/null +++ b/archetypes/business-service-jaxrs/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,42 @@ +<!-- + ~ 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. + --> +<archetype-descriptor + xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" + name="camel-archetype-java" + xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <fileSets> + <fileSet filtered="true" packaged="true" encoding="UTF-8"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="true" encoding="UTF-8"> + <directory>src/main/resources</directory> + <includes> + <include>**/*</include> + </includes> + </fileSet> + <fileSet encoding="UTF-8"> + <directory></directory> + <includes> + <include>README.md</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor> \ No newline at end of file diff --git a/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/README.md b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/README.md new file mode 100644 index 000000000..be5ae76ed --- /dev/null +++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/README.md @@ -0,0 +1,20 @@ +## Welcome to use ServiceComb Java Chassis +This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-jaxrs-archetype*, it use **jaxrs provider** to develop service producer. + +### More works can be done further: +1. Modify "HelloImpl", add your business service logic, or create some new producers to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-jax-rs/ +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/ +3. Modify setting value of "mainClass" in pom.xml for package. + +### Package your service +Under project(module) root folder, run +```bash +mvn package +``` +Then you can get outputs in target folder: +- lib : contains all dependencies jars +- xxxxxx-{version}.jar +```bash +java -jar xxxxxx-{version}.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.*** \ No newline at end of file diff --git a/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/pom.xml b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 000000000..2ad5a5e6b --- /dev/null +++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,117 @@ +<?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>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + <modelVersion>4.0.0</modelVersion> + + <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> + <!--for provider--> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>transport-rest-vertx</artifactId> + </dependency> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>transport-highway</artifactId> + </dependency> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>provider-jaxrs</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency> + + <!--for consumer--> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>provider-springmvc</artifactId> + </dependency> + </dependencies> + + <!--for package and deploy--> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.6</version> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathPrefix>lib/</classpathPrefix> + <!--change to your main class--> + <mainClass>${your-package}.Application</mainClass> + </manifest> + <manifestEntries> + <Class-Path>. </Class-Path> + </manifestEntries> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <phase>package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>target/lib</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/Application.java b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/Application.java similarity index 96% rename from archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/Application.java rename to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/Application.java index f803efcef..9371b4eed 100644 --- a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/Application.java +++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/Application.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; import org.apache.servicecomb.foundation.common.utils.BeanUtils; import org.apache.servicecomb.foundation.common.utils.Log4jUtils; diff --git a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java similarity index 96% rename from archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java rename to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java index 26c62057f..f89adf859 100644 --- a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java +++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; import org.springframework.web.client.RestTemplate; diff --git a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloImpl.java similarity index 90% rename from archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java rename to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloImpl.java index b8d787a97..25bc12f72 100644 --- a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java +++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloImpl.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; import javax.ws.rs.GET; import javax.ws.rs.Path; import org.apache.servicecomb.provider.rest.common.RestSchema; -@RestSchema(schemaId = "helloEndpoint") +@RestSchema(schemaId = "hello") @Path("/") -public class HelloEndpoint { +public class HelloImpl { @Path("/hello") @GET diff --git a/archetypes/business-service-pojo/src/main/resources/META-INF/spring/provider.bean.xml b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml similarity index 91% rename from archetypes/business-service-pojo/src/main/resources/META-INF/spring/provider.bean.xml rename to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml index 06e30f845..34a688dfb 100644 --- a/archetypes/business-service-pojo/src/main/resources/META-INF/spring/provider.bean.xml +++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml @@ -22,5 +22,6 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - <context:component-scan base-package="org.apache.servicecomb.archetypes"/> -</beans> \ No newline at end of file + <!--change to your schema(impl) bean package--> + <context:component-scan base-package="${groupId}"/> +</beans> diff --git a/archetypes/business-service-jaxrs/src/main/resources/microservice.yaml b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/resources/microservice.yaml similarity index 100% rename from archetypes/business-service-jaxrs/src/main/resources/microservice.yaml rename to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/resources/microservice.yaml diff --git a/archetypes/business-service-pojo/README.md b/archetypes/business-service-pojo/README.md index e6b7a4896..1e89e402c 100644 --- a/archetypes/business-service-pojo/README.md +++ b/archetypes/business-service-pojo/README.md @@ -1,8 +1,8 @@ ## Welcome to use ServiceComb Java Chassis -This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-pojo-archetype*, it use **pojo provider** to develop service endpoint. +This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-pojo-archetype*, it use **pojo provider** to develop service producer. ### 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/develop-with-transparent-rpc/ +1. Modify "HelloImpl", add your business service logic, or create some new producers to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-transparent-rpc/ 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/ 3. Modify setting value of "mainClass" in pom.xml for package. @@ -17,4 +17,4 @@ Then you can get outputs in target folder: ```bash java -jar xxxxxx-{version}.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.*** \ No newline at end of file +*Notice: If you need to modify configurations in "microservice.yaml" like service center address but don't want repackage the executable jar, **you can directly place a new "microservice.yaml" file under the same folder, then configurations will be overridden.*** \ No newline at end of file diff --git a/archetypes/business-service-pojo/pom.xml b/archetypes/business-service-pojo/pom.xml index 6dfe54c8d..23dac7b98 100644 --- a/archetypes/business-service-pojo/pom.xml +++ b/archetypes/business-service-pojo/pom.xml @@ -19,93 +19,43 @@ <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> + <groupId>org.apache.servicecomb</groupId> + <artifactId>archetypes</artifactId> + <version>1.0.0-m2-SNAPSHOT</version> + </parent> + <groupId>org.apache.servicecomb.archetypes</groupId> - <artifactId>business-service-pojo</artifactId> + <name>Java Chassis::Archetypes::POJO</name> + <artifactId>business-service-pojo-archetype</artifactId> + <packaging>maven-archetype</packaging> <modelVersion>4.0.0</modelVersion> - <version>1.0.0-m2-SNAPSHOT</version> <properties> - <java-chassis.version>1.0.0-m2-SNAPSHOT</java-chassis.version> + <maven-archetype-packaging-version>2.3</maven-archetype-packaging-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.apache.servicecomb</groupId> - <artifactId>transport-rest-vertx</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>transport-highway</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>provider-pojo</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </dependency> - </dependencies> - - <!--for package and deploy--> <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.6</version> - <configuration> - <archive> - <manifest> - <addClasspath>true</addClasspath> - <classpathPrefix>lib/</classpathPrefix> - <!--change to your main class--> - <mainClass>${your-package}.Application</mainClass> - </manifest> - <manifestEntries> - <Class-Path>. </Class-Path> - </manifestEntries> - </archive> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>copy-dependencies</id> - <phase>package</phase> - <goals> - <goal>copy-dependencies</goal> - </goals> - <configuration> - <outputDirectory>target/lib</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - </plugin> - </plugins> - </build> + <extensions> + <extension> + <groupId>org.apache.maven.archetype</groupId> + <artifactId>archetype-packaging</artifactId> + <version>${maven-archetype-packaging-version}</version> + </extension> + </extensions> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + </resource> + <resource> + <directory>src/main/resources-filtered</directory> + <filtering>true</filtering> + <includes> + <include>**/archetype-metadata.xml</include> + </includes> + </resource> + </resources> + </build> </project> \ No newline at end of file diff --git a/archetypes/business-service-pojo/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/archetypes/business-service-pojo/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml new file mode 100644 index 000000000..e953ae8b7 --- /dev/null +++ b/archetypes/business-service-pojo/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,42 @@ +<!-- + ~ 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. + --> +<archetype-descriptor + xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" + name="camel-archetype-java" + xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <fileSets> + <fileSet filtered="true" packaged="true" encoding="UTF-8"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="true" encoding="UTF-8"> + <directory>src/main/resources</directory> + <includes> + <include>**/*</include> + </includes> + </fileSet> + <fileSet encoding="UTF-8"> + <directory></directory> + <includes> + <include>README.md</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor> \ No newline at end of file diff --git a/archetypes/business-service-pojo/src/main/resources/archetype-resources/README.md b/archetypes/business-service-pojo/src/main/resources/archetype-resources/README.md new file mode 100644 index 000000000..b0905f7b5 --- /dev/null +++ b/archetypes/business-service-pojo/src/main/resources/archetype-resources/README.md @@ -0,0 +1,20 @@ +## Welcome to use ServiceComb Java Chassis +This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-pojo-archetype*, it use **pojo provider** to develop service producer. + +### More works can be done further: +1. Modify "HelloImpl", add your business service logic, or create some new producers to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-transparent-rpc/ +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/ +3. Modify setting value of "mainClass" in pom.xml for package. + +### Package your service +Under project(module) root folder, run +```bash +mvn package +``` +Then you can get outputs in target folder: +- lib : contains all dependencies jars +- xxxxxx-{version}.jar +```bash +java -jar xxxxxx-{version}.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.*** \ No newline at end of file diff --git a/archetypes/business-service-pojo/src/main/resources/archetype-resources/pom.xml b/archetypes/business-service-pojo/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 000000000..a1bcdabc7 --- /dev/null +++ b/archetypes/business-service-pojo/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,110 @@ +<?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>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + <modelVersion>4.0.0</modelVersion> + + <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.apache.servicecomb</groupId> + <artifactId>transport-rest-vertx</artifactId> + </dependency> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>transport-highway</artifactId> + </dependency> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>provider-pojo</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency> + </dependencies> + + <!--for package and deploy--> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.6</version> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathPrefix>lib/</classpathPrefix> + <!--change to your main class--> + <mainClass>${your-package}.Application</mainClass> + </manifest> + <manifestEntries> + <Class-Path>. </Class-Path> + </manifestEntries> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <phase>package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>target/lib</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/archetypes/business-service-springmvc/src/main/java/org/apache/servicecomb/archetypes/Application.java b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/Application.java similarity index 96% rename from archetypes/business-service-springmvc/src/main/java/org/apache/servicecomb/archetypes/Application.java rename to archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/Application.java index fd4ba248b..20ca721b6 100644 --- a/archetypes/business-service-springmvc/src/main/java/org/apache/servicecomb/archetypes/Application.java +++ b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/Application.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; import org.apache.servicecomb.foundation.common.utils.BeanUtils; import org.apache.servicecomb.foundation.common.utils.Log4jUtils; diff --git a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Hello.java b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/Hello.java similarity index 95% rename from archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Hello.java rename to archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/Hello.java index 301d40ede..1d7d65140 100644 --- a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Hello.java +++ b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/Hello.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; public interface Hello { String hello(); diff --git a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java similarity index 94% rename from archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java rename to archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java index 6e7e7428a..74ddadbee 100644 --- a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java +++ b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; import org.apache.servicecomb.provider.pojo.RpcReference; import org.springframework.stereotype.Component; @Component public class HelloConsumer { - @RpcReference(microserviceName = "business-service", schemaId = "helloEndpoint") + @RpcReference(microserviceName = "business-service", schemaId = "hello") private Hello hello; public Hello getHello() { diff --git a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/HelloImpl.java similarity index 87% rename from archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java rename to archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/HelloImpl.java index 303992155..487685a58 100644 --- a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java +++ b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/java/HelloImpl.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; import org.apache.servicecomb.provider.pojo.RpcSchema; -@RpcSchema(schemaId = "helloEndpoint") -public class HelloEndpoint implements Hello { +@RpcSchema(schemaId = "hello") +public class HelloImpl implements Hello { public String hello() { return "Hello World!"; diff --git a/archetypes/business-service-jaxrs/src/main/resources/META-INF/spring/provider.bean.xml b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml similarity index 91% rename from archetypes/business-service-jaxrs/src/main/resources/META-INF/spring/provider.bean.xml rename to archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml index 43399a5bd..34a688dfb 100644 --- a/archetypes/business-service-jaxrs/src/main/resources/META-INF/spring/provider.bean.xml +++ b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml @@ -22,6 +22,6 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - <!--change to your endpoint package--> - <context:component-scan base-package="org.apache.servicecomb.archetypes"/> + <!--change to your schema(impl) bean package--> + <context:component-scan base-package="${groupId}"/> </beans> diff --git a/archetypes/business-service-pojo/src/main/resources/microservice.yaml b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/resources/microservice.yaml similarity index 98% rename from archetypes/business-service-pojo/src/main/resources/microservice.yaml rename to archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/resources/microservice.yaml index ddf5f398d..90de8072f 100644 --- a/archetypes/business-service-pojo/src/main/resources/microservice.yaml +++ b/archetypes/business-service-pojo/src/main/resources/archetype-resources/src/main/resources/microservice.yaml @@ -30,7 +30,7 @@ service_description: name: business-service #Indicates a service version version: 1.0.0 -cse: +servicecomb: service: #Specifies the service center IP address. registry: diff --git a/archetypes/business-service-spring-boot-starter/README.md b/archetypes/business-service-spring-boot-starter/README.md index b3caa7d1d..9a6f2ee4a 100644 --- a/archetypes/business-service-spring-boot-starter/README.md +++ b/archetypes/business-service-spring-boot-starter/README.md @@ -1,8 +1,8 @@ ## 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. +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 producer. ### 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/develop-with-spring-boot-starter/ +1. Modify "HelloImpl", add your business service logic, or create some new producers to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-spring-boot-starter/ 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 @@ -15,11 +15,11 @@ Then you can get executable jar in target/bin folder: ```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.*** +*Notice: If you need to modify configurations in "microservice.yaml" like service center address but don't want repackage the executable jar, **you can directly place a new "microservice.yaml" file under the same folder, then configurations will be overridden.*** ## Spring Boot and ServiceComb ### Why ServiceComb make integration with Spring Boot -Spring Boot can accelerate develop speed of Spring application, it provide these features: +Spring Boot can accelerate develop speed of Spring application, it provides these features: * Can create independent executable Spring application * Tomcat embedded, Jetty as Web server, and do not need package(war) * Provide many starters in order to simplify maven dependency diff --git a/archetypes/business-service-spring-boot-starter/pom.xml b/archetypes/business-service-spring-boot-starter/pom.xml index 34c9e8b65..a767212bc 100644 --- a/archetypes/business-service-spring-boot-starter/pom.xml +++ b/archetypes/business-service-spring-boot-starter/pom.xml @@ -19,76 +19,43 @@ <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> + <groupId>org.apache.servicecomb</groupId> + <artifactId>archetypes</artifactId> + <version>1.0.0-m2-SNAPSHOT</version> + </parent> + <groupId>org.apache.servicecomb.archetypes</groupId> - <artifactId>business-service-spring-boot-starter</artifactId> + <name>Java Chassis::Archetypes::Spring Boot Starter</name> + <artifactId>business-service-spring-boot-starter-archetype</artifactId> + <packaging>maven-archetype</packaging> <modelVersion>4.0.0</modelVersion> - <version>1.0.0-m2-SNAPSHOT</version> <properties> - <java-chassis.version>1.0.0-m2-SNAPSHOT</java-chassis.version> - <springboot.version>1.4.5.RELEASE</springboot.version> + <maven-archetype-packaging-version>2.3</maven-archetype-packaging-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>${springboot.version}</version> - <executions> - <execution> - <goals> - <goal>repackage</goal> - </goals> - <configuration> - <outputDirectory>${project.build.directory}/bin</outputDirectory> - <classifier>exec</classifier> - </configuration> - </execution> - </executions> - </plugin> + <extensions> + <extension> + <groupId>org.apache.maven.archetype</groupId> + <artifactId>archetype-packaging</artifactId> + <version>${maven-archetype-packaging-version}</version> + </extension> + </extensions> - <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> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + </resource> + <resource> + <directory>src/main/resources-filtered</directory> + <filtering>true</filtering> + <includes> + <include>**/archetype-metadata.xml</include> + </includes> + </resource> + </resources> </build> - </project> \ No newline at end of file diff --git a/archetypes/business-service-spring-boot-starter/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/archetypes/business-service-spring-boot-starter/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml new file mode 100644 index 000000000..e953ae8b7 --- /dev/null +++ b/archetypes/business-service-spring-boot-starter/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,42 @@ +<!-- + ~ 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. + --> +<archetype-descriptor + xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" + name="camel-archetype-java" + xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <fileSets> + <fileSet filtered="true" packaged="true" encoding="UTF-8"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="true" encoding="UTF-8"> + <directory>src/main/resources</directory> + <includes> + <include>**/*</include> + </includes> + </fileSet> + <fileSet encoding="UTF-8"> + <directory></directory> + <includes> + <include>README.md</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor> \ No newline at end of file diff --git a/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/README.md b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/README.md new file mode 100644 index 000000000..af8baeaf0 --- /dev/null +++ b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/README.md @@ -0,0 +1,36 @@ +## 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 producer. + +### More works can be done further: +1. Modify "HelloImpl", add your business service logic, or create some new producers to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-spring-boot-starter/ +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.*** + +## Spring Boot and ServiceComb +### Why ServiceComb make integration with Spring Boot +Spring Boot can accelerate develop speed of Spring application, it provides these features: +* Can create independent executable Spring application +* Tomcat embedded, Jetty as Web server, and do not need package(war) +* Provide many starters in order to simplify maven dependency + +Using Spring Boot in microservice development, can greatly simplifying configure and deploy. ServiceComb is a microservice framework with full functionality of service management, focus on rapidly development of microservices, so integration with Spring Boot can obtain greater advantages. + +### How ServiceComb make integration with Spring Boot +Developers often use Spring Boot in the following way: +* Java application : import `spring-boot-starter` then develop general application, does not contain WEB +* Web application : import `spring-boot-starter-web` then develop web application, also include an embedded Tomcat or Jetty server, and use Spring Web MVC framework to develop REST endpoints + +The first way, do not need any refactoring, directly startup ServiceComb via Spring Boot. + +The second way is replace `Spring MVC DispatcherServlet` with `ServiceComb RestServlet`. \ No newline at end of file diff --git a/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/pom.xml b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 000000000..7d5282a10 --- /dev/null +++ b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/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>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + <modelVersion>4.0.0</modelVersion> + + <properties> + <java-chassis.version>1.0.0-m2-SNAPSHOT</java-chassis.version> + <springboot.version>1.4.5.RELEASE</springboot.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>${springboot.version}</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> \ No newline at end of file diff --git a/archetypes/business-service-spring-boot-starter/src/main/java/org/apache/servicecomb/archetypes/Application.java b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/java/Application.java similarity index 96% rename from archetypes/business-service-spring-boot-starter/src/main/java/org/apache/servicecomb/archetypes/Application.java rename to archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/java/Application.java index 2309563d3..c2e135ed5 100644 --- a/archetypes/business-service-spring-boot-starter/src/main/java/org/apache/servicecomb/archetypes/Application.java +++ b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/java/Application.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; import org.springframework.boot.SpringApplication; diff --git a/archetypes/business-service-spring-boot-starter/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java similarity index 96% rename from archetypes/business-service-spring-boot-starter/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java rename to archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java index 73917fd42..6fc027a0d 100644 --- a/archetypes/business-service-spring-boot-starter/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java +++ b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; import org.springframework.web.client.RestTemplate; diff --git a/archetypes/business-service-spring-boot-starter/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/java/HelloImpl.java similarity index 90% rename from archetypes/business-service-spring-boot-starter/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java rename to archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/java/HelloImpl.java index 888dbce1c..2a2589356 100644 --- a/archetypes/business-service-spring-boot-starter/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java +++ b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/java/HelloImpl.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; 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") +@RestSchema(schemaId = "hello") @RequestMapping(path = "/") -public class HelloEndpoint { +public class HelloImpl { @GetMapping(path = "/hello") public String hello() { diff --git a/archetypes/business-service-spring-boot-starter/src/main/resources/microservice.yaml b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/resources/microservice.yaml similarity index 98% rename from archetypes/business-service-spring-boot-starter/src/main/resources/microservice.yaml rename to archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/resources/microservice.yaml index ddf5f398d..90de8072f 100644 --- a/archetypes/business-service-spring-boot-starter/src/main/resources/microservice.yaml +++ b/archetypes/business-service-spring-boot-starter/src/main/resources/archetype-resources/src/main/resources/microservice.yaml @@ -30,7 +30,7 @@ service_description: name: business-service #Indicates a service version version: 1.0.0 -cse: +servicecomb: service: #Specifies the service center IP address. registry: diff --git a/archetypes/business-service-springmvc/README.md b/archetypes/business-service-springmvc/README.md index d7dde56f3..476c2f851 100644 --- a/archetypes/business-service-springmvc/README.md +++ b/archetypes/business-service-springmvc/README.md @@ -1,8 +1,8 @@ ## Welcome to use ServiceComb Java Chassis -This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-springmvc-archetype*, it use **springmvc provider** to develop service endpoint. +This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-springmvc-archetype*, it use **springmvc provider** to develop service producer. ### 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/develop-with-springmvc/ +1. Modify "HelloImpl", add your business service logic, or create some new producers to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-springmvc/ 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/ 3. Modify setting value of "mainClass" in pom.xml for package. @@ -17,4 +17,4 @@ Then you can get outputs in target folder: ```bash java -jar xxxxxx-{version}.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.*** \ No newline at end of file +*Notice: If you need to modify configurations in "microservice.yaml" like service center address but don't want repackage the executable jar, **you can directly place a new "microservice.yaml" file under the same folder, then configurations will be overridden.*** \ No newline at end of file diff --git a/archetypes/business-service-springmvc/pom.xml b/archetypes/business-service-springmvc/pom.xml index 2036be3c4..d3dc2f0db 100644 --- a/archetypes/business-service-springmvc/pom.xml +++ b/archetypes/business-service-springmvc/pom.xml @@ -19,93 +19,43 @@ <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> + <groupId>org.apache.servicecomb</groupId> + <artifactId>archetypes</artifactId> + <version>1.0.0-m2-SNAPSHOT</version> + </parent> + <groupId>org.apache.servicecomb.archetypes</groupId> - <artifactId>business-service-springmvc</artifactId> + <name>Java Chassis::Archetypes::Spring MVC</name> + <artifactId>business-service-springmvc-archetype</artifactId> + <packaging>maven-archetype</packaging> <modelVersion>4.0.0</modelVersion> - <version>1.0.0-m2-SNAPSHOT</version> <properties> - <java-chassis.version>1.0.0-m2-SNAPSHOT</java-chassis.version> + <maven-archetype-packaging-version>2.3</maven-archetype-packaging-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.apache.servicecomb</groupId> - <artifactId>transport-rest-vertx</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>transport-highway</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicecomb</groupId> - <artifactId>provider-springmvc</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </dependency> - </dependencies> - - <!--for package and deploy--> <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.6</version> - <configuration> - <archive> - <manifest> - <addClasspath>true</addClasspath> - <classpathPrefix>lib/</classpathPrefix> - <!--change to your main class--> - <mainClass>${your-package}.Application</mainClass> - </manifest> - <manifestEntries> - <Class-Path>. </Class-Path> - </manifestEntries> - </archive> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>copy-dependencies</id> - <phase>package</phase> - <goals> - <goal>copy-dependencies</goal> - </goals> - <configuration> - <outputDirectory>target/lib</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - </plugin> - </plugins> - </build> + <extensions> + <extension> + <groupId>org.apache.maven.archetype</groupId> + <artifactId>archetype-packaging</artifactId> + <version>${maven-archetype-packaging-version}</version> + </extension> + </extensions> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + </resource> + <resource> + <directory>src/main/resources-filtered</directory> + <filtering>true</filtering> + <includes> + <include>**/archetype-metadata.xml</include> + </includes> + </resource> + </resources> + </build> </project> \ No newline at end of file diff --git a/archetypes/business-service-springmvc/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/archetypes/business-service-springmvc/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml new file mode 100644 index 000000000..e953ae8b7 --- /dev/null +++ b/archetypes/business-service-springmvc/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,42 @@ +<!-- + ~ 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. + --> +<archetype-descriptor + xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" + name="camel-archetype-java" + xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <fileSets> + <fileSet filtered="true" packaged="true" encoding="UTF-8"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="true" encoding="UTF-8"> + <directory>src/main/resources</directory> + <includes> + <include>**/*</include> + </includes> + </fileSet> + <fileSet encoding="UTF-8"> + <directory></directory> + <includes> + <include>README.md</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor> \ No newline at end of file diff --git a/archetypes/business-service-springmvc/src/main/resources/archetype-resources/README.md b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/README.md new file mode 100644 index 000000000..eeb90dede --- /dev/null +++ b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/README.md @@ -0,0 +1,20 @@ +## Welcome to use ServiceComb Java Chassis +This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-springmvc-archetype*, it use **springmvc provider** to develop service producer. + +### More works can be done further: +1. Modify "HelloImpl", add your business service logic, or create some new producers to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-springmvc/ +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/ +3. Modify setting value of "mainClass" in pom.xml for package. + +### Package your service +Under project(module) root folder, run +```bash +mvn package +``` +Then you can get outputs in target folder: +- lib : contains all dependencies jars +- xxxxxx-{version}.jar +```bash +java -jar xxxxxx-{version}.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.*** \ No newline at end of file diff --git a/archetypes/business-service-springmvc/src/main/resources/archetype-resources/pom.xml b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 000000000..f3757b7e0 --- /dev/null +++ b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,110 @@ +<?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>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + <modelVersion>4.0.0</modelVersion> + + <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.apache.servicecomb</groupId> + <artifactId>transport-rest-vertx</artifactId> + </dependency> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>transport-highway</artifactId> + </dependency> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>provider-springmvc</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency> + </dependencies> + + <!--for package and deploy--> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.6</version> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathPrefix>lib/</classpathPrefix> + <!--change to your main class--> + <mainClass>${your-package}.Application</mainClass> + </manifest> + <manifestEntries> + <Class-Path>. </Class-Path> + </manifestEntries> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <phase>package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>target/lib</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Application.java b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/java/Application.java similarity index 96% rename from archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Application.java rename to archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/java/Application.java index fd4ba248b..20ca721b6 100644 --- a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Application.java +++ b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/java/Application.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; import org.apache.servicecomb.foundation.common.utils.BeanUtils; import org.apache.servicecomb.foundation.common.utils.Log4jUtils; diff --git a/archetypes/business-service-springmvc/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java similarity index 96% rename from archetypes/business-service-springmvc/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java rename to archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java index 73917fd42..6fc027a0d 100644 --- a/archetypes/business-service-springmvc/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java +++ b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; import org.springframework.web.client.RestTemplate; diff --git a/archetypes/business-service-springmvc/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/java/HelloImpl.java similarity index 90% rename from archetypes/business-service-springmvc/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java rename to archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/java/HelloImpl.java index 888dbce1c..2a2589356 100644 --- a/archetypes/business-service-springmvc/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java +++ b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/java/HelloImpl.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.servicecomb.archetypes; +package ${groupId}; 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") +@RestSchema(schemaId = "hello") @RequestMapping(path = "/") -public class HelloEndpoint { +public class HelloImpl { @GetMapping(path = "/hello") public String hello() { diff --git a/archetypes/business-service-springmvc/src/main/resources/META-INF/spring/provider.bean.xml b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml similarity index 94% rename from archetypes/business-service-springmvc/src/main/resources/META-INF/spring/provider.bean.xml rename to archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml index b62607191..4cab86d86 100644 --- a/archetypes/business-service-springmvc/src/main/resources/META-INF/spring/provider.bean.xml +++ b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml @@ -23,5 +23,5 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <!--change to your endpoint package--> - <context:component-scan base-package="org.apache.servicecomb.archetypes"/> + <context:component-scan base-package="${groupId}"/> </beans> \ No newline at end of file diff --git a/archetypes/business-service-springmvc/src/main/resources/microservice.yaml b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/resources/microservice.yaml similarity index 98% rename from archetypes/business-service-springmvc/src/main/resources/microservice.yaml rename to archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/resources/microservice.yaml index ddf5f398d..90de8072f 100644 --- a/archetypes/business-service-springmvc/src/main/resources/microservice.yaml +++ b/archetypes/business-service-springmvc/src/main/resources/archetype-resources/src/main/resources/microservice.yaml @@ -30,7 +30,7 @@ service_description: name: business-service #Indicates a service version version: 1.0.0 -cse: +servicecomb: service: #Specifies the service center IP address. registry: diff --git a/archetypes/pom.xml b/archetypes/pom.xml new file mode 100644 index 000000000..918dd5a5a --- /dev/null +++ b/archetypes/pom.xml @@ -0,0 +1,37 @@ +<!-- + ~ 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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.servicecomb</groupId> + <artifactId>java-chassis-parent</artifactId> + <version>1.0.0-m2-SNAPSHOT</version> + <relativePath>../parent</relativePath> + </parent> + + <artifactId>archetypes</artifactId> + <name>Java Chassis::Archetypes</name> + <packaging>pom</packaging> + <modules> + <module>business-service-jaxrs</module> + <module>business-service-pojo</module> + <module>business-service-springmvc</module> + <module>business-service-spring-boot-starter</module> + </modules> +</project> \ No newline at end of file diff --git a/java-chassis-dependencies/pom.xml b/java-chassis-dependencies/pom.xml index 970fc6beb..809eb15b2 100644 --- a/java-chassis-dependencies/pom.xml +++ b/java-chassis-dependencies/pom.xml @@ -1009,6 +1009,28 @@ <artifactId>metrics-prometheus</artifactId> <version>1.0.0-m2-SNAPSHOT</version> </dependency> + + <dependency> + <groupId>org.apache.servicecomb.archetypes</groupId> + <artifactId>business-service-jaxrs-archetype</artifactId> + <version>1.0.0-m2-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.servicecomb.archetypes</groupId> + <artifactId>business-service-pojo-archetype</artifactId> + <version>1.0.0-m2-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.servicecomb.archetypes</groupId> + <artifactId>business-service-springmvc-archetype</artifactId> + <version>1.0.0-m2-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.servicecomb.archetypes</groupId> + <artifactId>business-service-spring-boot-starter-archetype</artifactId> + <version>1.0.0-m2-SNAPSHOT</version> + </dependency> + </dependencies> </dependencyManagement> diff --git a/pom.xml b/pom.xml index e1ba8f670..9b03ed5e5 100644 --- a/pom.xml +++ b/pom.xml @@ -105,6 +105,7 @@ <module>edge</module> <module>metrics</module> <module>dynamic-config</module> + <module>archetypes</module> </modules> <profiles> ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services