mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:03:22 +08:00
Add build.gradle samples and rename runJar->bootRun
This commit is contained in:
parent
4c9c2b8dcf
commit
e55e8f9863
21
spring-boot-samples/spring-boot-sample-actuator/README.md
Normal file
21
spring-boot-samples/spring-boot-sample-actuator/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Spring Boot Actuator Sample
|
||||
|
||||
You can build this sample using Maven (>3) or Gradle (1.6).
|
||||
|
||||
With Maven:
|
||||
|
||||
```
|
||||
$ mvn package
|
||||
$ java -jar target/*.jar
|
||||
```
|
||||
|
||||
Then access the app via a browser (or curl) on http://localhost:8080 (the user name is "user" and look at the INFO log output for the password to login).
|
||||
|
||||
With gradle:
|
||||
|
||||
```
|
||||
$ gradle build
|
||||
$ java -jar build/libs/*.jar
|
||||
```
|
||||
|
||||
The gradle build contains an intentionally odd configuration to exclude the security dependencies from the executable JAR. So the app run like this behaves differently than the one run from the Maven-built JAR file. See comments in the `build.gradle` for details.
|
49
spring-boot-samples/spring-boot-sample-actuator/build.gradle
Normal file
49
spring-boot-samples/spring-boot-sample-actuator/build.gradle
Normal file
@ -0,0 +1,49 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url "http://repo.springsource.org/libs-snapshot" }
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.BUILD-SNAPSHOT")
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
springBootVersion = '0.5.0.BUILD-SNAPSHOT'
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
jar {
|
||||
baseName = 'spring-boot-sample-actuator'
|
||||
version = '0.5.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "http://repo.springsource.org/libs-snapshot" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
configurations {
|
||||
insecure.exclude module: 'spring-boot-starter-security'
|
||||
}
|
||||
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
|
||||
compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}")
|
||||
compile("org.springframework.boot:spring-boot-starter-security:${springBootVersion}")
|
||||
testCompile("junit:junit:4.11")
|
||||
insecure configurations.runtime
|
||||
}
|
||||
|
||||
// Slightly odd requirement (package a jar file as an insecure app, exlcuding Spring Security)
|
||||
// just to demonstrate the "customConfiguration" feature of the Boot gradle plugin.
|
||||
springBoot {
|
||||
customConfiguration = "insecure"
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '1.6'
|
||||
}
|
19
spring-boot-samples/spring-boot-sample-simple/README.md
Normal file
19
spring-boot-samples/spring-boot-sample-simple/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Spring Boot Simple Sample
|
||||
|
||||
You can build this sample using Maven (>3) or Gradle (1.6).
|
||||
|
||||
With Maven:
|
||||
|
||||
```
|
||||
$ mvn package
|
||||
$ java -jar target/*.jar
|
||||
```
|
||||
|
||||
The app prints a Hello message on the console.
|
||||
|
||||
With gradle:
|
||||
|
||||
```
|
||||
$ gradle build
|
||||
$ java -jar build/libs/*.jar
|
||||
```
|
37
spring-boot-samples/spring-boot-sample-simple/build.gradle
Normal file
37
spring-boot-samples/spring-boot-sample-simple/build.gradle
Normal file
@ -0,0 +1,37 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url "http://repo.springsource.org/libs-snapshot" }
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.BUILD-SNAPSHOT")
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
springBootVersion = '0.5.0.BUILD-SNAPSHOT'
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
jar {
|
||||
baseName = 'spring-boot-sample-simple'
|
||||
version = '0.5.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "http://repo.springsource.org/libs-snapshot" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter:${springBootVersion}")
|
||||
testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '1.6'
|
||||
}
|
@ -44,6 +44,13 @@ $ gradle build
|
||||
$ java -jar build/libs/mymodule-0.0.1-SNAPSHOT.jar
|
||||
```
|
||||
|
||||
### Running a Project in Place
|
||||
|
||||
To run a project in place without building a jar first you can use the "bootRun" task:
|
||||
|
||||
```
|
||||
$ gradle bootRun
|
||||
```
|
||||
|
||||
### Repackage configuration
|
||||
The gradle plugin automatically extends your build script DSL with a `springBoot` element
|
||||
|
@ -25,7 +25,7 @@ import org.springframework.boot.gradle.task.Repackage;
|
||||
import org.springframework.boot.gradle.task.RunJar;
|
||||
|
||||
/**
|
||||
* Gradle 'Spring Boot' {@link Plugin}.
|
||||
* Gradle 'Spring Boot' {@link Plugin}. Provides 2 tasks (bootRepackge and bootRun).
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@ -33,7 +33,7 @@ public class SpringBootPlugin implements Plugin<Project> {
|
||||
|
||||
private static final String REPACKAGE_TASK_NAME = "bootRepackage";
|
||||
|
||||
private static final String RUN_JAR_TASK_NAME = "runJar";
|
||||
private static final String RUN_JAR_TASK_NAME = "bootRun";
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
|
Loading…
Reference in New Issue
Block a user