例
取得したいファイルを、-fオプションに指定する。$ readlink -f hoge.txt
/home/hoge/hoge.txt
$ readlink -f hoge.txt
/home/hoge/hoge.txt
$ curl -s http://localhost:9200/test_index/hoge/1 | jq
{
"_index": "test_index",
"_type": "hoge",
"_id": "1",
"_version": 3,
"found": true,
"_source": {
"hoge1": "hoge1",
"hoge2": "fuga2"
}
}
$ curl -XPOST -H "Content-Type: application/json" http://localhost:9200/test_index/hoge/1/_update -d '
{
"doc": {
"hoge1": "mod-hoge1"
}
}
'
$ curl -s http://localhost:9200/test_index/hoge/1 | jq
{
"_index": "test_index",
"_type": "hoge",
"_id": "1",
"_version": 4,
"found": true,
"_source": {
"hoge1": "mod-hoge1",
"hoge2": "fuga2"
}
}
"name","age"
"hoge,fuga", 100
package main
import (
"encoding/csv"
"fmt"
"io"
"log"
"os"
)
func main() {
// ファイルを開く
file, err := os.Open("test.csv")
if err != nil {
log.Fatal(err)
}
// 開いたファイルの後始末
defer file.Close()
// CSVを読み込むためのReaderを生成
reader := csv.NewReader(file)
for {
// 1行づつ読み込む
record, err := reader.Read()
// ファイルの末尾で処理終了
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
fmt.Println(record)
}
}
[name age]
[hoge,fuga 100]
mvn spring-boot:run -Dspring-boot.run.arguments=[引数]
testCompile 'org.assertj:assertj-core:3.11.1'
public class SampleTest {
@RegisterExtension
public final JUnitJupiterSoftAssertions softly = new JUnitJupiterSoftAssertions();
@Test
void test() {
softly.assertThat(5)
.isEqualTo(1);
softly.assertThat("hoge")
.isEqualTo("fuga");
}
}
Expected :1
Actual :5
<Click to see difference>
Expected :fuga
Actual :hoge
<Click to see difference>
stage('test') {
steps {
script {
pom = readMavenPom file: 'pom.xml'
println(pom.version)
pom.dependencies.each {
println(it)
}
}
}
}
[Pipeline] readMavenPom
[Pipeline] echo
1.0.0
[Pipeline] echo
Dependency {groupId=org.springframework.boot, artifactId=spring-boot-starter-data-jpa, version=null, type=jar}
[Pipeline] echo
Dependency {groupId=org.springframework.boot, artifactId=spring-boot-starter-thymeleaf, version=null, type=jar}
[Pipeline] echo
Dependency {groupId=org.springframework.boot, artifactId=spring-boot-starter-web, version=null, type=jar}
[Pipeline] echo
Dependency {groupId=org.springframework.boot, artifactId=spring-boot-starter-actuator, version=null, type=jar}
[Pipeline] echo
Dependency {groupId=org.postgresql, artifactId=postgresql, version=null, type=jar}
[Pipeline] echo
Dependency {groupId=org.springframework.boot, artifactId=spring-boot-starter-test, version=null, type=jar}
[Pipeline] }
# maven-resourceの定義
resource_types:
- name: maven-resource
type: docker-image
source:
repository: nulldriver/maven-resource
tag: latest
resources:
- name: app
type: git
source:
uri: http://gitbucket:8080/git/root/sample-app.git
# maven-resourceのリソース定義
# urlや接続情報などを設定します
- name: nexus
type: maven-resource
source:
url: http://nexus:8081/repository/maven-releases/
snapshot_url: http://nexus:8081/repository/maven-snapshots/
artifact: sample:sample-app:jar
username: admin
password: admin123
jobs:
- name: build
plan:
- get: app
trigger: true
- task: build
config:
platform: linux
image_resource:
type: docker-image
source:
repository: maven
tag: '3.5.4-jdk-8'
inputs:
- name: app
# putでmavenリポジトリに成果物をデプロイできるようにするためのoutputsの定義
outputs:
- name: target
run:
path: bash
args:
- -c
- |
cd app
mvn clean package -D maven.repo.local=/tmp/.m2/repository
cp -r target ..
# jarとpomを指定してリポジトリにデプロイします
- put: nexus
params:
file: target/sample-app*.jar
pom_file: app/pom.xml
[INFO] --- maven-deploy-plugin:2.7:deploy-file (default-cli) @ standalone-pom ---
Downloading: http://nexus:8081/repository/maven-snapshots/sample/sample-app/1.0.0-SNAPSHOT/maven-metadata.xml
Uploading: http://nexus:8081/repository/maven-snapshots/sample/sample-app/1.0.0-SNAPSHOT/sample-app-1.0.0-20180715.115944-1.jar
Uploaded: http://nexus:8081/repository/maven-snapshots/sample/sample-app/1.0.0-SNAPSHOT/sample-app-1.0.0-20180715.115944-1.jar (1.8 kB at 8.4 kB/s)
Uploading: http://nexus:8081/repository/maven-snapshots/sample/sample-app/1.0.0-SNAPSHOT/sample-app-1.0.0-20180715.115944-1.pom
Uploaded: http://nexus:8081/repository/maven-snapshots/sample/sample-app/1.0.0-SNAPSHOT/sample-app-1.0.0-20180715.115944-1.pom (403 B at 5.2 kB/s)
Downloading: http://nexus:8081/repository/maven-snapshots/sample/sample-app/maven-metadata.xml
Uploading: http://nexus:8081/repository/maven-snapshots/sample/sample-app/1.0.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://nexus:8081/repository/maven-snapshots/sample/sample-app/1.0.0-SNAPSHOT/maven-metadata.xml (766 B at 9.9 kB/s)
Uploading: http://nexus:8081/repository/maven-snapshots/sample/sample-app/maven-metadata.xml
Uploaded: http://nexus:8081/repository/maven-snapshots/sample/sample-app/maven-metadata.xml (276 B at 4.1 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
$ ls .m2
ls: '.m2' にアクセスできません: そのようなファイルやディレクトリはありません
$ mvn package -Dmaven.repo.local=./.m2/repository
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< sample:sample-app >--------------------------
[INFO] Building sample-app 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
*************************************** 省略 ***************************************
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:25 min
[INFO] Finished at: 2018-07-15T06:37:10+09:00
[INFO] ------------------------------------------------------------------------
$ ls .m2
repository
public class Sample {
public final String name;
public final short age;
@JsonCreator
public Sample(
@JsonProperty("name") final String name,
@JsonProperty("age") final short age) {
this.name = name;
this.age = age;
}
@Override
public String toString() {
return "Sample{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
}
public class Sample {
public final String name;
public final short age;
private Sample(final String name, final short age) {
this.name = name;
this.age = age;
}
@JsonCreator
public static Sample create(
@JsonProperty("name") final String name,
@JsonProperty("age") final short age) {
return new Sample(name, age);
}
@Override
public String toString() {
return "Sample{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
}
final ObjectMapper objectMapper = new ObjectMapper();
final Sample sample = objectMapper.readValue("{\"name\": \"なまえ\", \"age\": 100}", Sample.class);
System.out.println("sample = " + sample);
sample = Sample{name='なまえ', age=100}
bindkey '^R' history-incremental-pattern-search-backward
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
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest()
.authenticated()
.and()
.formLogin()
.defaultSuccessUrl("/index", true)
.and()
.logout()
.invalidateHttpSession(true);
}
spring.flyway.baseline-on-migrate=true
spring.flyway.baseline-version=001
create table test
(
id int not null
primary key,
num1 int,
num2 int,
num3 as [num1] + [num2]
)
insert into test (id, num1, num2) values (1, 1, 2)
1> select * from test
2> go
id num1 num2 num3
----------- ----------- ----------- -----------
1 1 2 3
(1 rows affected)
override fun doPost(req: HttpServletRequest, resp: HttpServletResponse) {
println("Content-Length: ${req.contentLengthLong}")
println("parameter count: ${req.parameterMap.size}")
req.parameterMap.forEach {
println("${it.key}: ${it.value.joinToString(", ")}")
}
doGet(req, resp)
}
➜ ~ curl http://localhost:8080/sample/hello --data-urlencode "param_key=値" -X POST -i
HTTP/1.1 200
Content-Length: 19
parameter count: 1
param_key: 値
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
maxPostSize="1"
redirectPort="8443" />
➜ ~ curl http://localhost:8080/sample/hello --data-urlencode "param_key=値" -X POST -i
HTTP/1.1 200
Content-Length: 19
parameter count: 0
<filter>
<filter-name>failedRequestFilter</filter-name>
<filter-class>org.apache.catalina.filters.FailedRequestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>failedRequestFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
➜ ~ curl http://localhost:8080/sample/hello --data-urlencode "param_key=値" -X POST -i
HTTP/1.1 413
➜ ~ curl http://localhost:8080/sample/hello -H "Content-Type: application/json" -d "{}" -i
HTTP/1.1 200
org.codehaus.mojo:versions-maven-plugin:2.5:update-parent
で参照可能な最新バージョンに変更できる。org.codehaus.mojo:versions-maven-plugin:2.5:update-parent -DparentVersion=[1.0.0,1.1.0]
mvn org.codehaus.mojo:versions-maven-plugin:2.5:set -DremoveSnapshot=true
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filesets>
<fileset>
<directory>temp</directory>
<includes>
<include>*.log</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.4'
@JacksonXmlRootElement(localName = "root")
public class Simple {
private Child child;
public Child getChild() {
return child;
}
public void setChild(final Child child) {
this.child = child;
}
@Override
public String toString() {
return "Simple{" +
"child=" + child +
'}';
}
}
public class Child {
@JacksonXmlText
private String text;
@JacksonXmlProperty(isAttribute = true)
private String attr;
@Override
public String toString() {
return "Child{" +
"text='" + text + '\'' +
", attr='" + attr + '\'' +
'}';
}
}
final String xml = "あたい ";
final XmlMapper xmlMapper = new XmlMapper();
final Simple simple = xmlMapper.readValue(xml, Simple.class);
System.out.println("simple = " + simple); // simple = Simple{child=Child{text='あたい', attr='hoge'}}
final Simple input = new Simple();
final Child child = new Child();
child.text = "値";
child.attr = "属性";
input.child = child;
System.out.println(xmlMapper.writeValueAsString(input)); // 値
compile 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.4'
@JacksonXmlRootElement(localName = "r")
data class Hoge(val hoge:String)
val xmlMapper = XmlMapper()
xmlMapper.registerModule(KotlinModule())
println(xmlMapper.writeValueAsString(Hoge("fugafuga")))
1> create sequence test
2> go
1>
1> select start_value from sys.sequences where name = 'test'
2> go
start_value
-----------
-9223372036854775808
1> create sequence test start with 1
2> go
1>
1> select start_value from sys.sequences where name = 'test'
2> go
start_value
-----------
1