起動引数は、システムプロパティのspring-boot.run.argumentsを使用して指定します。
mvn spring-boot:run -Dspring-boot.run.arguments=[引数]mvn spring-boot:run -Dspring-boot.run.arguments=[引数]public class Form {
private Boolean check;
// ほかは省略
}@PostMapping("hello")
public String hello(Form form) {
System.out.println("form.check = " + form.check);
return "input";
}
<form th:action="@{/hello}" method="post" th:object="${form}">
<input type="checkbox" th:field="*{check}" />
<button type="submit">submit</button>
</form>
<form action="/hello" method="post">
<input type="checkbox" id="check1" name="check" value="true" /><input type="hidden" name="_check" value="on"/>
<button type="submit">submit</button>
</form>
form.check = false<form action="/hello" method="post">
<input type="checkbox" name="checkbox" />
<button type="submit">submit</button>
</form>
<form action="/hello" method="post">
<input type="checkbox" value="on" id="check1" name="check"/><input type="hidden" name="_check" value="on"/>
<button type="submit">submit</button>
</form>
<form th:action="@{/hello}" method="post" th:object="${form}">
<input type="checkbox" th:field="*{check}" value="on" />
<input type="hidden" name="!check" value="off" />
<button type="submit">submit</button>
</form>
form.check = off
spring.flyway.baseline-on-migrate=true
spring.flyway.baseline-version=001
compile 'org.thymeleaf.extras:thymeleaf-extras-java8time:2.1.0.RELEASE'
<span th:text="${#temporals.format(nowDateTime, 'yyyy/MM/dd HH:mm:ss')}"></span>@Component
@ConfigurationProperties(prefix = "sample")
public class SampleConfiguration {
private String name;
private String hoge;
// setterとgetterは省略
}
buildscript {
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/plugins-release' }
}
dependencies {
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
}
}
configure(allprojects) {
apply plugin: 'propdeps'
apply plugin: 'propdeps-maven'
apply plugin: 'propdeps-idea'
apply plugin: 'propdeps-eclipse'
}
dependencies {
optional "org.springframework.boot:spring-boot-configuration-processor"
}
compileJava.dependsOn(processResources)
{
"groups": [{
"name": "sample",
"type": "com.example.SampleConfiguration",
"sourceType": "com.example.SampleConfiguration"
}],
"properties": [
{
"name": "sample.hoge",
"type": "java.lang.String",
"description": "ほげ",
"sourceType": "com.example.SampleConfiguration"
},
{
"name": "sample.name",
"type": "java.lang.String",
"description": "名前",
"sourceType": "com.example.SampleConfiguration"
}
],
"hints": []
}