當我在使用 Windows 10 的時候,從工作管理員發現,磁碟使用率常滿載,一直 90 ~ 100%,嚴重影響整體效能
How-To
解決方式分成兩方面:
在 C 槽按右鍵,將以下 checkbox uncheck,按下確定即可
到控制台 -> 服務,找到 Windows Search 此服務,將其 Stop 並將啟動類型設為手動
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | package test.albert.jackson; import lombok.Builder; import lombok.Data; @Data @Builder public class Employee { private Integer id; private String name; private String email; private String phone; private Address address; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | package test.albert.jackson; import lombok.Builder; import lombok.Data; @Data @Builder public class Address { private String streetAddress; private String city; private String zipCode; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | package test.albert.jackson; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; @Slf4j public class JacksonTest { public static void main(String[] args) throws JsonProcessingException { Address address = Address.builder().zipCode("110").city("台北市").streetAddress("信義區信義路五段7號").build(); Employee albert = Employee.builder().id(1).name("Albert").email("albert@gmail.com").phone("0900123456") .address(address).build(); ObjectMapper mapper = new ObjectMapper(); String json = mapper.writeValueAsString(albert); log.debug(json); } } |
1 2 3 4 5 6 7 8 9 10 11 | { "id": 1, "name": "Albert", "email": "albert@gmail.com", "phone": "0900123456", "address": { "streetAddress": "信義區信義路五段7號", "city": "台北市", "zipCode": "110" } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | package test.albert.jackson; import lombok.Builder; import lombok.Data; @Data @Builder public class Employee { @JsonIgnore private Integer id; private String name; private String email; private String phone; private Address address; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | package test.albert.jackson; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Builder; import lombok.Data; @Data @Builder @JsonIgnoreProperties({"id", "phone"}) public class Employee { private Integer id; private String name; private String email; private String phone; private Address address; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | package test.albert.jackson; import com.fasterxml.jackson.annotation.JsonIgnoreType; import lombok.Builder; import lombok.Data; @Data @Builder @JsonIgnoreType public class Address { private String streetAddress; private String city; private String zipCode; } |
1 2 3 4 5 6 7 8 | <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:SchemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>C:\Users\albert\.m2</localRepository> </settings> |
1 | mvn -o -Dmaven.repo.local=”C:\Users\albert\.m2" clean install -Dmaven.test.skip=true -X |
1 2 3 4 5 6 7 8 9 10 11 | image: maven:3.3.3-jdk-7 build: stage: build script: - "mvn clean install -Dmaven.test.skip=true" artifacts: expire_in: 1 week when: on_success paths: - target/*.jar |
1 2 3 4 5 6 7 8 9 10 | image: maven:3-jdk-7 build: stage: build script: "mvn clean package -U" artifacts: expire_in: 1 week when: always paths: - target/*.war |
mvn install:install-file -Dfile=db2jcc4-4.22.29.jar -DgroupId="com.ibm.db2.jcc" -DartifactId="db2jcc4" -Dversion="4.22.29" -Dpackaging="jar"
<dependency> <groupId>com.ibm.db2.jcc</groupId> <artifactId>db2jcc4</artifactId> <version>4.22.29</version> </dependency>
<repositories> <repository> <id>my-local-repo</id> <!-- ${basedir} represents the directory containing pom.xml --> <url>file://${basedir}/local-repo</url> </repository> </repositories>
fatal: LF would be replaced by CRLF
for /f %f IN ( 'dir /b /s *.xml *.pom *.sha1' ) DO @unix2dos %f
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.dbutils.QueryRunner; public class DaoBase { public Connection getConnection() throws SQLException { return MyDataSource.getInstance().getDatasource().getConnection(); } public List<Map<String, Object>> find(String sql) throws SQLException { List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>(); Connection con = null; Statement stmt = null; ResultSet rs = null; try { con = getConnection(); stmt = con.createStatement(); rs = stmt.executeQuery(sql); // ... } catch (SQLException e) { throw e; } finally { if(rs != null) { rs.close(); } if(stmt != null) { stmt.close(); } if(con != null) { con.close(); } } return datas; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.dbutils.QueryRunner; public class DaoBase { public Connection getConnection() throws SQLException { return MyDataSource.getInstance().getDatasource().getConnection(); } public List<Map<String, Object>> find(String sql) throws SQLException { List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>(); Connection con = null; Statement stmt = null; ResultSet rs = null; try { con = getConnection(); stmt = con.createStatement(); rs = stmt.executeQuery(sql); // ignore... } catch (SQLException e) { throw e; } finally { close(rs); close(stmt); close(con); } return datas; } public void close(ResultSet rs) { if (rs != null) { try { rs.close(); } catch (SQLException e) { } } } public void close(Statement stmt) { if (stmt != null) { try { stmt.close(); } catch (SQLException e) { } } } public void close(Connection con) { if (con != null) { try { con.close(); } catch (SQLException e) { } } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public List<AccountDtl> getAcctDetail(List<String> acctNos) throws SQLException { List<AccountDtl> result = new ArrayList<AccountDtl>(); Connection conn = null; PreparedStatement pst = null; ResultSet rs = null; String accounts = ""; for (String account : acctNos) { accounts = accounts + "'" + account + "',"; } String sql = "select DISTINCT ( TRIM(REC_ID)) , NO , ID from " + Table.test.getFullName() + " where acct_no in (" + accounts.substring(0, accounts.length() - 1) + ")"; try { conn = getConnection(); pst = conn.prepareStatement(sql); rs = pst.executeQuery(); // ignore code snippet regarding get values } catch (SQLException e) { throw e; } finally { close(rs); close(pst); close(conn); } return result; } |
1 2 3 4 5 | <dependency> <groupId>org.owasp.esapi</groupId> <artifactId>esapi</artifactId> <version>2.1.0</version> </dependency> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import org.owasp.esapi.ESAPI; import org.owasp.esapi.codecs.DB2Codec; // ignore code snippet public List<AccountDtl> getAcctDetail(List<String> acctNos) throws SQLException { List<AccountDtl> result = new ArrayList<AccountDtl>(); Connection conn = null; PreparedStatement pst = null; ResultSet rs = null; String accounts = ""; for (String account : acctNos) { accounts = accounts + "'" + ESAPI.encoder().encodeForSQL(new DB2Codec(), account) + "',"; } String sql = "select DISTINCT ( TRIM(REC_ID)) , NO , ID from " + Table.test.getFullName() + " where acct_no in (" + accounts.substring(0, accounts.length() - 1) + ")"; try { conn = getConnection(); pst = conn.prepareStatement(sql); rs = pst.executeQuery(); // ignore code snippet regarding get values } catch (SQLException e) { throw e; } finally { close(rs); close(pst); close(conn); } return result; } |