demo-java-spring-boot-rest

Demo Java Spring Boot REST with Gradle, MVC, Actuator, Integration Testing, and more

https://github.com/joelparkerhenderson/demo-java-spring-boot-rest

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.1%) to scientific vocabulary
Last synced: 8 months ago · JSON representation ·

Repository

Demo Java Spring Boot REST with Gradle, MVC, Actuator, Integration Testing, and more

Basic Info
  • Host: GitHub
  • Owner: joelparkerhenderson
  • Default Branch: master
  • Size: 531 KB
Statistics
  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created almost 10 years ago · Last pushed about 1 year ago
Metadata Files
Readme Citation

README.md

Demo Java Spring Boot REST

Spring logo

See http://projects.spring.io/spring-boot/

From the Spring website: "Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration."

To create this demo

Verify you have Java 1.7 or better:

$ java -version
java version "1.8.0_72"

Verify you have Gradle 2.14 or better:

$ gradle -version
Gradle 2.14

Generate a project:

  • Go to http://start.spring.io/
  • Type "com.example.foo" and "demo".
  • Select "Gradle" (not "Maven").
  • Choose "Web" then "SpringMVC".
  • Download the zip file.
  • Unzip it.

Build:

$ ./gradlew build

Run:

$ java -jar build/libs/demo-0.0.1-SNAPSHOT.jar

Browse:

http://localhost:8080

You should see a web page that says "Hello World".

Extras

This demo also adds:

  • A unit test.
  • An integration test.
  • Actuator, which provides health check monitoring.

To change ports

There are several ways to change the port number.

Using a Java command line option:

$ java -Dserver.port=9999 -jar build/libs/demo-0.0.1-SNAPSHOT.jar

Using an environment variable:

$ SERVER_PORT=9999 java -jar build/libs/demo-0.0.1-SNAPSHOT.jar

Using the file application.properties in src/main/resources/:

server.port=9999

Using the file application.properties with a custom command line variable:

server.port=${myport:8080}

$ java -Dmyport=9999 -jar build/libs/demo-0.0.1-SNAPSHOT.jar

Using the file application.yml:

server.port: 9999

Using source code:

@Controller
public class ServletConfig {
    @Bean
    public EmbeddedServletContainerCustomizer containerCustomizer() {
        return (container -> {
            container.setPort(9999);
        });
    }
}

Using a scan for a free port, and using OS natives to prevent clashes: use port 0.

To switch off the HTTP endpoints completely, but still create a WebApplicationContext, use port 1. This is sometimes useful for testing.

Owner

  • Name: Joel Parker Henderson
  • Login: joelparkerhenderson
  • Kind: user
  • Location: California

Software developer. Technology consultant. Creator of GitAlias.com, NumCommand.com, SixArm.com, and many open source projects.

Citation (CITATION.cff)

cff-version: 1.2.0
title: Demo Java Spring Boot REST
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/joelparkerhenderson/demo-java-spring-boot-rest/'
    description: Demo Java Spring Boot REST
repository-code: 'https://github.com/joelparkerhenderson/demo-java-spring-boot-rest/'
abstract: >-
  Demo Java Spring Boot REST
license: See license file

GitHub Events

Total
  • Watch event: 1
  • Push event: 1
Last Year
  • Watch event: 1
  • Push event: 1

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 6
  • Total Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 6
Committer Domains (Top 20 + Academic)

Dependencies

demo/build.gradle maven
  • org.springframework.boot:spring-boot-starter-actuator * compile
  • org.springframework.boot:spring-boot-starter-web * compile
  • org.springframework.boot:spring-boot-starter-test * testCompile