Skip to content

Commit 6f2673b

Browse files
author
Ray Tsang
committed
Initial commit for Spring Boot example.
1 parent 4461fbd commit 6f2673b

7 files changed

Lines changed: 183 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Managed VMs on Google Cloud Platform use the [Java Servlets](http://www.oracle.c
77

88
1. [Helloworld-servlet](helloworld-servlet) Servlet based Hello World app
99
1. [HelloWorld-jsp](helloworld-jsp) Java Server Pages based Hello World app
10+
1. [HelloWorld-springboot](helloworld-springboot) Spring Boot based Hello World app
1011
1. [Bookshelf](bookshelf) A full featured app that demonstrates Authentication and CRUD operations for [Cloud Datastore](https://cloud.google.com/datastore/docs/concepts/overview?hl=en) and [Cloud SQL](https://cloud.google.com/sql/docs/introduction).
1112

1213
## Contributing changes

helloworld-springboot/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Spring Boot based Hello World app
2+
3+
## Requirements
4+
* [Apache Maven](http://maven.apache.org) 3.1 or greater
5+
* JDK 8 in order to run
6+
* [Cloud SDK for Managed VMs](https://cloud.google.com/appengine/docs/managed-vms/)
7+
8+
## Run the Application locally
9+
1. Set the correct Cloud SDK project via `gcloud config set project YOUR_PROJECT`
10+
id of your application.
11+
2. Run `mvn spring-boot:run`
12+
4. Visit http://localhost:8080
13+
14+
## Deploy to AppEngine Managed VMs
15+
16+
5. `mvn gcloud:deploy`
17+
6. Visit `http://YOUR_PROJECT.appspot.com`.

helloworld-springboot/pom.xml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright (c) 2013 Google Inc. All Rights Reserved.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License"); you
6+
~ may not use this file except in compliance with the License. You may
7+
~ obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14+
~ implied. See the License for the specific language governing
15+
~ permissions and limitations under the License.
16+
-->
17+
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
22+
<groupId>com.example.java.gettingstarted</groupId>
23+
<artifactId>helloworld-springboot</artifactId>
24+
<version>0.0.1-SNAPSHOT</version>
25+
<packaging>jar</packaging>
26+
27+
<name>helloworld-springboot</name>
28+
<description>Demo project for Spring Boot</description>
29+
30+
<parent>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter-parent</artifactId>
33+
<version>1.3.2.RELEASE</version>
34+
<relativePath/> <!-- lookup parent from repository -->
35+
</parent>
36+
37+
<properties>
38+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
39+
<java.version>1.8</java.version>
40+
</properties>
41+
42+
<dependencies>
43+
<dependency>
44+
<groupId>org.springframework.boot</groupId>
45+
<artifactId>spring-boot-starter-web</artifactId>
46+
</dependency>
47+
48+
<dependency>
49+
<groupId>org.springframework.boot</groupId>
50+
<artifactId>spring-boot-starter-test</artifactId>
51+
<scope>test</scope>
52+
</dependency>
53+
</dependencies>
54+
55+
<build>
56+
<plugins>
57+
<plugin>
58+
<groupId>org.springframework.boot</groupId>
59+
<artifactId>spring-boot-maven-plugin</artifactId>
60+
</plugin>
61+
<!-- START plugin -->
62+
<plugin>
63+
<groupId>com.google.appengine</groupId>
64+
<artifactId>gcloud-maven-plugin</artifactId>
65+
<version>2.0.9.95.v20160203</version>
66+
</plugin>
67+
<!-- END plugin -->
68+
</plugins>
69+
</build>
70+
</project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# [START_EXCLUDE]
2+
# Copyright 2015 Google Inc. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# [END_EXCLUDE]
16+
runtime: java
17+
vm: true
18+
19+
runtime_config: # Optional
20+
jdk: openjdk8
21+
22+
handlers:
23+
- url: /.*
24+
script: this field is required, but ignored
25+
secure: always # Require HTTPS
26+
27+
manual_scaling:
28+
instances: 1
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2015 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.example.java.gettingstarted;
17+
18+
import org.springframework.boot.SpringApplication;
19+
import org.springframework.boot.autoconfigure.SpringBootApplication;
20+
import org.springframework.web.bind.annotation.RestController;
21+
import org.springframework.web.bind.annotation.RequestMapping;
22+
23+
@SpringBootApplication
24+
@RestController
25+
public class HelloworldApplication {
26+
@RequestMapping("/")
27+
public String home() {
28+
return "Hello World!";
29+
}
30+
31+
public static void main(String[] args) {
32+
SpringApplication.run(HelloworldApplication.class, args);
33+
}
34+
}

helloworld-springboot/src/main/resources/application.properties

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright 2015 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.example.java.gettingstarted;
17+
18+
import org.junit.Test;
19+
import org.junit.runner.RunWith;
20+
import org.springframework.test.context.web.WebAppConfiguration;
21+
import org.springframework.boot.test.SpringApplicationConfiguration;
22+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
23+
24+
@RunWith(SpringJUnit4ClassRunner.class)
25+
@SpringApplicationConfiguration(classes = HelloworldApplication.class)
26+
@WebAppConfiguration
27+
public class HelloworldApplicationTests {
28+
29+
@Test
30+
public void contextLoads() {
31+
}
32+
33+
}

0 commit comments

Comments
 (0)