This is an automated email from the ASF dual-hosted git repository. mabin pushed a commit to branch houserush-sample in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git
commit 015e63035ac4f162b9c33a0d3cc4e59060a4a835 Author: liubao <[email protected]> AuthorDate: Tue Mar 12 20:24:50 2019 +0800 [SCB-1193]upgread spring boot versions and add easy to use dependency - samples --- README.md | 3 + dependency_management/spring4/pom.xml | 67 ++++++++++++++++++ .../samples/dependencyManagement/Application.java | 26 +++++++ .../dependencyManagement/HelloEndpoint.java | 32 +++++++++ .../spring4/src/main/resources/log4j2.xml | 43 ++++++++++++ .../spring4/src/main/resources/microservice.yaml | 36 ++++++++++ dependency_management/spring5/pom.xml | 67 ++++++++++++++++++ .../samples/dependencyManagement/Application.java | 26 +++++++ .../dependencyManagement/HelloEndpoint.java | 32 +++++++++ .../spring5/src/main/resources/log4j2.xml | 43 ++++++++++++ .../spring5/src/main/resources/microservice.yaml | 36 ++++++++++ dependency_management/springboot1/pom.xml | 81 ++++++++++++++++++++++ .../samples/dependencyManagement/Application.java | 30 ++++++++ .../dependencyManagement/HelloEndpoint.java | 32 +++++++++ .../springboot1/src/main/resources/application.yml | 35 ++++++++++ dependency_management/springboot2/pom.xml | 77 ++++++++++++++++++++ .../samples/dependencyManagement/Application.java | 30 ++++++++ .../dependencyManagement/HelloEndpoint.java | 32 +++++++++ .../springboot2/src/main/resources/application.yml | 35 ++++++++++ 19 files changed, 763 insertions(+) diff --git a/README.md b/README.md index ac5abc5..0c15baf 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,6 @@ ## porter_lightweight A sample shows an application with basic login, download file, delete file functions. + +## dependency_management +A sample shows how to use dependency management to create spring 4, spring 5, spring boot 1 or spring boot 2 application. \ No newline at end of file diff --git a/dependency_management/spring4/pom.xml b/dependency_management/spring4/pom.xml new file mode 100644 index 0000000..9ee8710 --- /dev/null +++ b/dependency_management/spring4/pom.xml @@ -0,0 +1,67 @@ +<!-- ~ 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> + + <groupId>org.apache.servicecomb.samples.dependencyManagement</groupId> + <artifactId>spring4</artifactId> + <version>0.0.1</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <java.version>1.8</java.version> + <argLine>-Dfile.encoding=UTF-8</argLine> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <main.class>org.apache.servicecomb.samples.dependencyManagement.Application</main.class> + </properties> + + <dependencyManagement> + <dependencies> + <!-- need to compile lastest java-chassis code --> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>java-chassis-dependencies-spring4</artifactId> + <version>1.2.0-SNAPSHOT</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>solution-basic</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </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/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java b/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java new file mode 100644 index 0000000..335c7a5 --- /dev/null +++ b/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java @@ -0,0 +1,26 @@ +/* + * 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.samples.dependencyManagement; + +import org.apache.servicecomb.foundation.common.utils.BeanUtils; + +public class Application { + public static void main(String[] args) throws Exception { + BeanUtils.init(); + } +} diff --git a/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java b/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java new file mode 100644 index 0000000..51923d8 --- /dev/null +++ b/dependency_management/spring4/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java @@ -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.samples.dependencyManagement; + +import org.apache.servicecomb.provider.rest.common.RestSchema; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@RestSchema(schemaId = "hello") +@RequestMapping(path = "/") +public class HelloEndpoint { + @GetMapping(path = "/hello") + public String hello(@RequestParam(name = "name") String name) { + return name; + } +} diff --git a/dependency_management/spring4/src/main/resources/log4j2.xml b/dependency_management/spring4/src/main/resources/log4j2.xml new file mode 100644 index 0000000..e3afdb6 --- /dev/null +++ b/dependency_management/spring4/src/main/resources/log4j2.xml @@ -0,0 +1,43 @@ +<?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. + --> + +<!--this is sample configuration, please modify as your wish--> + +<configuration> + <Properties> + <Property name="log_path">./file/log/</Property> + </Properties> + + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/> + </Console> + <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log" + filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log"> + <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/> + <TimeBasedTriggeringPolicy interval="1"/> + <SizeBasedTriggeringPolicy size="10 MB"/> + </RollingFile> + </Appenders> + <Loggers> + <Root level="info"> + <AppenderRef ref="Console"/> + <AppenderRef ref="DailyRollingFile"/> + </Root> + </Loggers> +</configuration> \ No newline at end of file diff --git a/dependency_management/spring4/src/main/resources/microservice.yaml b/dependency_management/spring4/src/main/resources/microservice.yaml new file mode 100644 index 0000000..e5e3410 --- /dev/null +++ b/dependency_management/spring4/src/main/resources/microservice.yaml @@ -0,0 +1,36 @@ +# +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# override common configurations in common module +servicecomb-config-order: 10 + +APPLICATION_ID: dependency_management + +service_description: + version: 0.0.1 + name: spring4 + +servicecomb: + service: + registry: + address: http://localhost:30100 + instance: + watch: false + + rest: + address: 0.0.0.0:9090 \ No newline at end of file diff --git a/dependency_management/spring5/pom.xml b/dependency_management/spring5/pom.xml new file mode 100644 index 0000000..375c070 --- /dev/null +++ b/dependency_management/spring5/pom.xml @@ -0,0 +1,67 @@ +<!-- ~ 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> + + <groupId>org.apache.servicecomb.samples.dependencyManagement</groupId> + <artifactId>spring5</artifactId> + <version>0.0.1</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <java.version>1.8</java.version> + <argLine>-Dfile.encoding=UTF-8</argLine> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <main.class>org.apache.servicecomb.samples.dependencyManagement.Application</main.class> + </properties> + + <dependencyManagement> + <dependencies> + <!-- need to compile lastest java-chassis code --> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>java-chassis-dependencies-spring5</artifactId> + <version>1.2.0-SNAPSHOT</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>solution-basic</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </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/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java b/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java new file mode 100644 index 0000000..335c7a5 --- /dev/null +++ b/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java @@ -0,0 +1,26 @@ +/* + * 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.samples.dependencyManagement; + +import org.apache.servicecomb.foundation.common.utils.BeanUtils; + +public class Application { + public static void main(String[] args) throws Exception { + BeanUtils.init(); + } +} diff --git a/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java b/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java new file mode 100644 index 0000000..51923d8 --- /dev/null +++ b/dependency_management/spring5/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java @@ -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.samples.dependencyManagement; + +import org.apache.servicecomb.provider.rest.common.RestSchema; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@RestSchema(schemaId = "hello") +@RequestMapping(path = "/") +public class HelloEndpoint { + @GetMapping(path = "/hello") + public String hello(@RequestParam(name = "name") String name) { + return name; + } +} diff --git a/dependency_management/spring5/src/main/resources/log4j2.xml b/dependency_management/spring5/src/main/resources/log4j2.xml new file mode 100644 index 0000000..e3afdb6 --- /dev/null +++ b/dependency_management/spring5/src/main/resources/log4j2.xml @@ -0,0 +1,43 @@ +<?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. + --> + +<!--this is sample configuration, please modify as your wish--> + +<configuration> + <Properties> + <Property name="log_path">./file/log/</Property> + </Properties> + + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/> + </Console> + <RollingFile name="DailyRollingFile" fileName="${log_path}/output.log" + filePattern="${log_path}/zcrTest%d{yyyy-MM-dd}.log"> + <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n"/> + <TimeBasedTriggeringPolicy interval="1"/> + <SizeBasedTriggeringPolicy size="10 MB"/> + </RollingFile> + </Appenders> + <Loggers> + <Root level="info"> + <AppenderRef ref="Console"/> + <AppenderRef ref="DailyRollingFile"/> + </Root> + </Loggers> +</configuration> \ No newline at end of file diff --git a/dependency_management/spring5/src/main/resources/microservice.yaml b/dependency_management/spring5/src/main/resources/microservice.yaml new file mode 100644 index 0000000..3efb2e2 --- /dev/null +++ b/dependency_management/spring5/src/main/resources/microservice.yaml @@ -0,0 +1,36 @@ +# +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# override common configurations in common module +servicecomb-config-order: 10 + +APPLICATION_ID: dependency_management + +service_description: + version: 0.0.1 + name: spring5 + +servicecomb: + service: + registry: + address: http://localhost:30100 + instance: + watch: false + + rest: + address: 0.0.0.0:9090 \ No newline at end of file diff --git a/dependency_management/springboot1/pom.xml b/dependency_management/springboot1/pom.xml new file mode 100644 index 0000000..da6b1a7 --- /dev/null +++ b/dependency_management/springboot1/pom.xml @@ -0,0 +1,81 @@ +<!-- ~ 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> + + <groupId>org.apache.servicecomb.samples.dependencyManagement</groupId> + <artifactId>springboot1</artifactId> + <version>0.0.1</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <java.version>1.8</java.version> + <argLine>-Dfile.encoding=UTF-8</argLine> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <main.class>org.apache.servicecomb.samples.dependencyManagement.Application</main.class> + </properties> + + <dependencyManagement> + <dependencies> + <!-- need to compile lastest java-chassis code --> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>java-chassis-dependencies-springboot1</artifactId> + <version>1.2.0-SNAPSHOT</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>solution-basic</artifactId> + <exclusions> + <exclusion> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>spring-boot-starter-transport</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </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/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java b/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java new file mode 100644 index 0000000..072a201 --- /dev/null +++ b/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java @@ -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.samples.dependencyManagement; + +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) throws Exception { + SpringApplication.run(Application.class, args); + } +} diff --git a/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java b/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java new file mode 100644 index 0000000..51923d8 --- /dev/null +++ b/dependency_management/springboot1/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java @@ -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.samples.dependencyManagement; + +import org.apache.servicecomb.provider.rest.common.RestSchema; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@RestSchema(schemaId = "hello") +@RequestMapping(path = "/") +public class HelloEndpoint { + @GetMapping(path = "/hello") + public String hello(@RequestParam(name = "name") String name) { + return name; + } +} diff --git a/dependency_management/springboot1/src/main/resources/application.yml b/dependency_management/springboot1/src/main/resources/application.yml new file mode 100644 index 0000000..590d7b6 --- /dev/null +++ b/dependency_management/springboot1/src/main/resources/application.yml @@ -0,0 +1,35 @@ +# +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +server: + port: 9090 + +APPLICATION_ID: dependency_management + +service_description: + version: 0.0.1 + name: springboot1 + +servicecomb: + service: + registry: + address: http://localhost:30100 + instance: + watch: false + + rest: + address: 0.0.0.0:9090 \ No newline at end of file diff --git a/dependency_management/springboot2/pom.xml b/dependency_management/springboot2/pom.xml new file mode 100644 index 0000000..8cb3bd9 --- /dev/null +++ b/dependency_management/springboot2/pom.xml @@ -0,0 +1,77 @@ +<!-- ~ 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> + + <groupId>org.apache.servicecomb.samples.dependencyManagement</groupId> + <artifactId>springboot2</artifactId> + <version>0.0.1</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <java.version>1.8</java.version> + <argLine>-Dfile.encoding=UTF-8</argLine> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <main.class>org.apache.servicecomb.samples.dependencyManagement.Application</main.class> + </properties> + + <dependencyManagement> + <dependencies> + <!-- need to compile lastest java-chassis code --> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>java-chassis-dependencies-springboot2</artifactId> + <version>1.2.0-SNAPSHOT</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>solution-basic</artifactId> + <exclusions> + <exclusion> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.servicecomb</groupId> + <artifactId>spring-boot2-starter-servlet</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </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/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java b/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java new file mode 100644 index 0000000..876b1a2 --- /dev/null +++ b/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/Application.java @@ -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.samples.dependencyManagement; + +import org.apache.servicecomb.springboot2.starter.EnableServiceComb; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.SpringApplication; + +@SpringBootApplication +@EnableServiceComb +public class Application { + public static void main(String[] args) throws Exception { + SpringApplication.run(Application.class, args); + } +} diff --git a/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java b/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java new file mode 100644 index 0000000..51923d8 --- /dev/null +++ b/dependency_management/springboot2/src/main/java/org/apache/servicecomb/samples/dependencyManagement/HelloEndpoint.java @@ -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.samples.dependencyManagement; + +import org.apache.servicecomb.provider.rest.common.RestSchema; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@RestSchema(schemaId = "hello") +@RequestMapping(path = "/") +public class HelloEndpoint { + @GetMapping(path = "/hello") + public String hello(@RequestParam(name = "name") String name) { + return name; + } +} diff --git a/dependency_management/springboot2/src/main/resources/application.yml b/dependency_management/springboot2/src/main/resources/application.yml new file mode 100644 index 0000000..cab54c0 --- /dev/null +++ b/dependency_management/springboot2/src/main/resources/application.yml @@ -0,0 +1,35 @@ +# +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +server: + port: 9090 + +APPLICATION_ID: dependency_management + +service_description: + version: 0.0.1 + name: springboot2 + +servicecomb: + service: + registry: + address: http://localhost:30100 + instance: + watch: false + + rest: + address: 0.0.0.0:9090 \ No newline at end of file
