BAEL-1635: Spring Boot CLI (#3886)

* BAEL-1635: Spring Boot CLI

* Modified packages for consistent naming
This commit is contained in:
Adam InTae Gerard 2018-03-31 11:45:58 -07:00 committed by KevinGilmore
parent 6549e41afa
commit 323f5bf370
9 changed files with 122 additions and 27 deletions

View File

@ -0,0 +1,6 @@
=========
## Spring Boot CLI
### Relevant Articles:
- [Introduction to Spring Boot CLI](http://www.baeldung.com/)

View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
echo "Run Groovy Service or Script"
echo "spring run app.groovy"
spring run app.groovy
echo
echo "Watch Groovy Service or Script"
echo "spring run app.groovy --watch"
spring run app.groovy --watch
echo
echo "Spring Shell"
echo "spring shell"
spring shell
echo "now enter a spring command..."
echo

View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
echo "Install SDKMan"
sudo apt-get update
sudo apt-get install unzip zip -y
sudo curl -s get.sdkman.io | bash
sudo source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk version
echo "Install Spring Dependencies"
sudo sdk install groovy
sudo sdk install java
sudo sdk install maven
echo "Install Spring Boot"
sudo sdk install springboot
spring --version
# Spring Boot CLI Proper
# sdk install springboot dev /path/to/spring-boot/spring-boot-cli/target/spring-boot-cli-2.0.0.RELEASE-bin/spring-2.0.0.RELEASE/
# sdk default springboot dev
# spring --version

View File

@ -0,0 +1,23 @@
package bael.data
@Grab('h2')
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType
import org.springframework.web.servlet.config.annotation.EnableWebMvc
import javax.sql.DataSource
@Configuration
@EnableWebMvc
@ComponentScan('bael.data')
class DataConfig {
@Bean
DataSource dataSource() {
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build();
}
}

View File

@ -0,0 +1,12 @@
package bael.security
@Grab("spring-boot-starter-security")
@RestController
class SampleController {
@RequestMapping("/")
public def example() {
[message: "Hello World!"]
}
}

View File

@ -0,0 +1,12 @@
package bael.test
@Grab('junit')
@Log
class Test {
static void main(String[] args) {
log.info "Test..."
}
}

View File

@ -0,0 +1,17 @@
package bael.yml
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.context.annotation.ComponentScan
@EnableAutoConfiguration
@ComponentScan('bael.yml')
class App {
static void main(String[] args) {
new SpringApplicationBuilder()
.sources(App)
.run(args)
}
}

View File

@ -0,0 +1,2 @@
spring:
port: 8081

View File

@ -1,33 +1,20 @@
#!/usr/bin/env bash
echo See: https://howtoprogram.xyz/2016/08/28/install-spring-boot-command-line-interface-on-linux/
echo
echo "Setting up Java JDK 8"
echo See: http://tipsonubuntu.com/2016/07/31/install-oracle-java-8-9-ubuntu-16-04-linux-mint-18/
sudo add-apt-repository ppa:webupd8team/java
echo "Install SDKMan"
sudo apt-get update
sudo apt-get install oracle-java8-set-default
echo
sudo apt-get install unzip zip -y
sudo curl -s get.sdkman.io | bash
sudo source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk version
echo "Downloading Spring Boot CLI 1.5.7"
wget http://repo.spring.io/release/org/springframework/boot/spring-boot-cli/1.5.7.RELEASE/spring-boot-cli-1.5.7.RELEASE-bin.tar.gz
echo
echo "Install Spring Dependencies"
sudo sdk install groovy
sudo sdk install java
sudo sdk install maven
echo "Extracting and Installing"
sudo mkdir /opt/spring-boot
sudo tar xzf spring-boot-cli-1.5.7.RELEASE-bin.tar.gz -C /opt/spring-boot
export SPRING_HOME=/opt/spring-boot/spring-1.5.7.RELEASE
export PATH=$SPRING_HOME/bin:$PATH
source /etc/profile
echo
echo "Verifying Install of Spring CLI"
echo "Install Spring Boot"
sudo sdk install springboot
spring --version
echo
echo "Maven Install"
sudo apt-get install maven
echo
echo "Installing JCE"
sudo apt-get install p7zip-full
@ -41,9 +28,6 @@ sudo mv UnlimitedJCEPolicyJDK8/*.jar /usr/lib/jvm/java-8-oracle/jre/lib/security
echo
echo "Installing Spring Cloud CLI"
sudo mkdir /opt/spring-boot/spring-1.5.7.RELEASE/lib/ext
sudo chown -R $USER:$USER /opt/spring-boot/spring-1.5.7.RELEASE/lib/ext
echo see: https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-cli/ if manual install required
spring install org.springframework.cloud:spring-cloud-cli:1.3.2.RELEASE
echo