[实习记录]总结陈词

1. docker

  • 日常使用: docker ps\docker inspect\docker images\docker-compose up (-d)\docker pull&push

  • 写docker-compose文件: .env\environment初始化docker\registry.docker-cn.com国内镜像加速\ports\volumes\restart\container_name\depends_on

mongodb:
    image: registry.docker-cn.com/library/mongo
    env_file: docker-compose.env
    ports:
      - 27018:27017
    restart: always
    environment:
      MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE}
      MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
      MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
    volumes:
      - /home/kk/data/mongod/datadir:/data/db
    logging:
      driver: json-file
      options:
        max-size: "10"
    container_name: mongodb
  • 写dockerfile: from\label\env\cmd\copy\jar包\docker build -t example .

FROM openjdk:8-jre-alpine
LABEL kk
ENV TZ=Asia/Shanghai
RUN apk add --update --no-cache tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone
WORKDIR /app
COPY build/libs/example.jar /app/
CMD ["java", "-jar", "-Dspring.profiles.active=prod", "/app/example.jar"]

2. Gradle

buildscript {
    ext {
        springBootVersion = '1.4.2.RELEASE'
        dcm4cheVersion = '5.13.0'
        commonioVersion = '2.6'
        jedisVersion = '2.9.0'
        redisVersion = '1.8.4.RELEASE'
    }
    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'http://www.dcm4che.org/maven2/' }
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

jar {
    baseName = 'example'
    version = '1.0.0'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    maven { url 'http://www.dcm4che.org/maven2/' }
    mavenCentral()
}

dependencies {
    testCompile('org.springframework.boot:spring-boot-starter-test')
    compile("redis.clients:jedis:${jedisVersion}")
    compile("org.springframework.data:spring-data-redis:${redisVersion}")
    compile("org.dcm4che:dcm4che-imageio:${dcm4cheVersion}")
    compile("org.dcm4che:dcm4che-net:${dcm4cheVersion}")
    compile("org.dcm4che.tool:dcm4che-tool-storescu:${dcm4cheVersion}")
    compile("org.dcm4che:dcm4che-core:${dcm4cheVersion}")
    compile("org.dcm4che.tool:dcm4che-tool-common:${dcm4cheVersion}")
    compile("commons-io:commons-io:${commonioVersion}")
    configurations.all {
        exclude module: 'slf4j-log4j12'
    }
}

3.mybatis&JPA: plugin mybatis free

4. flywaydb:ALTER TABLE

5. service&impl: 接口不变只改变底层实现部分

6. @cache&@transactional&@scheduled

    @Transactional(rollbackFor = {DataAccessException.class, DataIntegrityViolationException.class})
        try {
            //TODO
        } catch (DataIntegrityViolationException e) {
            logger.error("[Error] : data integrity error\n " + e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return "Failure";
        } catch (DataAccessException e) {
            logger.error("[Error] : database access error\n " + e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return "Failure";
        }
    @CachePut(key = "#label_project.project")
    @Cacheable(key = "#p0")

7.logging&logback




     
    

    
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
        
    

    
        
            ${log_home}/log/${appname}.%d{yyyy-MM-dd}.log
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
        
    

    
        
    

    
        
    


8. application.yml: spring profiles active

@ConfigurationProperties(prefix = "tx.data.paths") 
@EnableConfigurationProperties(TXDataPaths.class)
spring:
  profiles: prod
  data:
    mongodb:
      uri: mongodb://username:password@localhost:27018/database?authSource=admin
  datasource:
    url: jdbc:mysql://localhost:3307/db_infervision?useUnicode=true&characterEncoding=utf-8
    username: 
    password: 
  redis:
    host: localhost
    port: 6380
logging:
  config: classpath:logback-spring.xml

9. 程序启动前出错,终止程序;程序运行期间出错,保证程序持续运行.

10. spring-data-mongodb:

upsert:
    public Label_Project upsertByDescription(Label_Project label_project) {
        Query query = new Query();
        query.addCriteria(Criteria.where("project").is(label_project.getProject()));
        Update update = new Update();
        update.set("project", label_project.getProject());
        update.set("remark", label_project.getRemark());
        WriteResult result = mongoTemplate.upsert(query, update, Label_Project.class);
        return label_project;
    }
exist不能使用,原因不明.

11. 数据库批量操作


    
        INSERT INTO label_level(
        
        )VALUES
        
            (
            #{pojo.id},
            #{pojo.type},
            #{pojo.content},
            #{pojo.levelName}
            )
        
    

12. 文件监控:commonio\读取csv文件:commoncsv

13. 对象参数获取返回值:spring-data-mongodb的model不适用(原因不明)

14. .gitignore

15. git:git add\git commit -m\git branch\git checkout\git reset -hard\git merge\git rebase\git pull origin master\arc diff\arc land\

你可能感兴趣的:([实习记录]总结陈词)