Created
May 2, 2018 06:23
-
-
Save raymondmars/f90de81277ff952f76c89a0597e249fb to your computer and use it in GitHub Desktop.
Springboot demo bash script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
springdemopath=./demo/src/main/java/com/demo/test && mkdir -p "$springdemopath" && touch "$springdemopath/Application.java" && { cat >> "$springdemopath/Application.java" <<-EOF | |
package com.demo.test; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
@SpringBootApplication | |
@RestController | |
public class Application { | |
@RequestMapping("/") | |
public String home() { | |
return "hello, world!"; | |
} | |
public static void main(String[] args) { | |
SpringApplication.run(Application.class, args); | |
} | |
} | |
EOF | |
} && touch ./demo/pom.xml && { cat >> ./demo/pom.xml <<-EOF | |
<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/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.demo</groupId> | |
<artifactId>test</artifactId> | |
<packaging>jar</packaging> | |
<version>1.0.0</version> | |
<parent> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-parent</artifactId> | |
<version>2.0.1.RELEASE</version> | |
<relativePath/> | |
</parent> | |
<dependencies> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-web</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-test</artifactId> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-maven-plugin</artifactId> | |
</plugin> | |
</plugins> | |
</build> | |
</project> | |
EOF | |
} && cd ./demo && mvn spring-boot:run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run as below:
sh ./springboot.sh