Skip to content

Commit 323f5bf

Browse files
ThoughtscriptKevinGilmore
authored andcommitted
BAEL-1635: Spring Boot CLI (eugenp#3886)
* BAEL-1635: Spring Boot CLI * Modified packages for consistent naming
1 parent 6549e41 commit 323f5bf

File tree

9 files changed

+124
-29
lines changed

9 files changed

+124
-29
lines changed

spring-boot-cli/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=========
2+
3+
## Spring Boot CLI
4+
5+
### Relevant Articles:
6+
- [Introduction to Spring Boot CLI](http://www.baeldung.com/)

spring-boot-cli/bash/groovy.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
echo "Run Groovy Service or Script"
4+
echo "spring run app.groovy"
5+
spring run app.groovy
6+
echo
7+
8+
echo "Watch Groovy Service or Script"
9+
echo "spring run app.groovy --watch"
10+
spring run app.groovy --watch
11+
echo
12+
13+
echo "Spring Shell"
14+
echo "spring shell"
15+
spring shell
16+
echo "now enter a spring command..."
17+
echo

spring-boot-cli/bash/setup.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
echo "Install SDKMan"
4+
sudo apt-get update
5+
sudo apt-get install unzip zip -y
6+
sudo curl -s get.sdkman.io | bash
7+
sudo source "$HOME/.sdkman/bin/sdkman-init.sh"
8+
sdk version
9+
10+
echo "Install Spring Dependencies"
11+
sudo sdk install groovy
12+
sudo sdk install java
13+
sudo sdk install maven
14+
15+
echo "Install Spring Boot"
16+
sudo sdk install springboot
17+
spring --version
18+
19+
# Spring Boot CLI Proper
20+
# 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/
21+
# sdk default springboot dev
22+
# spring --version
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package bael.data
2+
3+
@Grab('h2')
4+
5+
import org.springframework.context.annotation.Bean
6+
import org.springframework.context.annotation.ComponentScan
7+
import org.springframework.context.annotation.Configuration
8+
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder
9+
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType
10+
import org.springframework.web.servlet.config.annotation.EnableWebMvc
11+
import javax.sql.DataSource
12+
13+
@Configuration
14+
@EnableWebMvc
15+
@ComponentScan('bael.data')
16+
class DataConfig {
17+
18+
@Bean
19+
DataSource dataSource() {
20+
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build();
21+
}
22+
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package bael.security
2+
3+
@Grab("spring-boot-starter-security")
4+
5+
@RestController
6+
class SampleController {
7+
8+
@RequestMapping("/")
9+
public def example() {
10+
[message: "Hello World!"]
11+
}
12+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package bael.test
2+
3+
@Grab('junit')
4+
@Log
5+
6+
class Test {
7+
8+
static void main(String[] args) {
9+
log.info "Test..."
10+
}
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package bael.yml
2+
3+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
4+
import org.springframework.boot.builder.SpringApplicationBuilder
5+
import org.springframework.context.annotation.ComponentScan
6+
7+
@EnableAutoConfiguration
8+
@ComponentScan('bael.yml')
9+
class App {
10+
11+
static void main(String[] args) {
12+
new SpringApplicationBuilder()
13+
.sources(App)
14+
.run(args)
15+
}
16+
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
spring:
2+
port: 8081

spring-cloud-cli/install.sh

+13-29
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,20 @@
11
#!/usr/bin/env bash
2-
echo See: https://howtoprogram.xyz/2016/08/28/install-spring-boot-command-line-interface-on-linux/
3-
echo
42

5-
echo "Setting up Java JDK 8"
6-
echo See: http://tipsonubuntu.com/2016/07/31/install-oracle-java-8-9-ubuntu-16-04-linux-mint-18/
7-
sudo add-apt-repository ppa:webupd8team/java
3+
echo "Install SDKMan"
84
sudo apt-get update
9-
sudo apt-get install oracle-java8-set-default
10-
echo
11-
12-
echo "Downloading Spring Boot CLI 1.5.7"
13-
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
14-
echo
15-
16-
echo "Extracting and Installing"
17-
sudo mkdir /opt/spring-boot
18-
sudo tar xzf spring-boot-cli-1.5.7.RELEASE-bin.tar.gz -C /opt/spring-boot
19-
export SPRING_HOME=/opt/spring-boot/spring-1.5.7.RELEASE
20-
export PATH=$SPRING_HOME/bin:$PATH
21-
source /etc/profile
22-
echo
23-
24-
echo "Verifying Install of Spring CLI"
5+
sudo apt-get install unzip zip -y
6+
sudo curl -s get.sdkman.io | bash
7+
sudo source "$HOME/.sdkman/bin/sdkman-init.sh"
8+
sdk version
9+
10+
echo "Install Spring Dependencies"
11+
sudo sdk install groovy
12+
sudo sdk install java
13+
sudo sdk install maven
14+
15+
echo "Install Spring Boot"
16+
sudo sdk install springboot
2517
spring --version
26-
echo
27-
28-
echo "Maven Install"
29-
sudo apt-get install maven
30-
echo
3118

3219
echo "Installing JCE"
3320
sudo apt-get install p7zip-full
@@ -41,9 +28,6 @@ sudo mv UnlimitedJCEPolicyJDK8/*.jar /usr/lib/jvm/java-8-oracle/jre/lib/security
4128
echo
4229

4330
echo "Installing Spring Cloud CLI"
44-
sudo mkdir /opt/spring-boot/spring-1.5.7.RELEASE/lib/ext
45-
sudo chown -R $USER:$USER /opt/spring-boot/spring-1.5.7.RELEASE/lib/ext
46-
echo see: https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-cli/ if manual install required
4731
spring install org.springframework.cloud:spring-cloud-cli:1.3.2.RELEASE
4832
echo
4933

0 commit comments

Comments
 (0)