首页 » 2018年11月

Failed to execute goal com.spotify:docker-maven-plugin:0.2.3:build (default-cli) on project thor-quest: Exception caught: UNC path is missing sharename: /

这个是dockerdirectory配置不对导致,还有要去掉,具体如下


<build>
        <finalName>thor-quest</finalName>
        <plugins>
         
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>1.2.0</version>
                <configuration>
                    <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                    <dockerDirectory>${project.basedir}</dockerDirectory>
                    <resources>
                        <resource>
                            <!--<targetPath>/</targetPath>-->
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                </configuration>
            </plugin>
        </plugins>
    </build>

阿里云的日志系统比elk还是好用多了,而且支持像sql那样查询日志。接入方法如下


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    ​
    <springProperty scope="context" name="springAppName" source="spring.application.name"/>
    <springProperty scope="context" name="mytopic" source="spring.application.name"/>
    <springProperty scope="context" name="myprofile" source="spring.profiles.active"/>
    <!-- Example for logging into the build folder of your project -->
    <property name="LOG_FILE" value="/data/logs/${mytopic}.log"/>​

    <!-- You can override this to have a custom pattern -->
    <property name="CONSOLE_LOG_PATTERN"
              value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr([${springAppName:-},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]){yellow} %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>

    <!-- Appender to log to console -->
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <!-- Minimum logging level to be presented in the console logs-->
            <level>DEBUG</level>
        </filter>
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            <charset>utf8</charset>
        </encoder>
    </appender>

    <!-- Appender to log to file -->​
    <appender name="flatfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_FILE}</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.gz</fileNamePattern>
            <maxHistory>7</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            <charset>utf8</charset>
        </encoder>
    </appender>
    ​

    <appender name="loghubAppender1" class="com.aliyun.openservices.log.logback.LoghubAppender">
        <!--必选项-->
        <!-- 账号及网络配置 -->
        <endpoint>xxxx-3.log.aliyuncs.com</endpoint>
        <accessKeyId>xxxxxxx</accessKeyId>
        <accessKey>xxxxxxxx</accessKey>

        <!-- sls 项目配置 -->
        <projectName>thor1108</projectName>
        <logstore>thor-${myprofile}</logstore>
        <!--必选项 (end)-->

        <!-- 可选项 -->
        <topic>${mytopic}</topic>

        <!-- 可选项 详见 '参数说明'-->
        <packageTimeoutInMS>3000</packageTimeoutInMS>
        <logsCountPerPackage>4096</logsCountPerPackage>
        <logsBytesPerPackage>3145728</logsBytesPerPackage>
        <memPoolSizeInByte>104857600</memPoolSizeInByte>
        <retryTimes>3</retryTimes>
        <maxIOThreadSizeInPool>8</maxIOThreadSizeInPool>

        <!-- 可选项 通过配置 encoder 的 pattern 自定义 log 的格式 -->
        <encoder>
            <pattern>
                    {
                        "severity": "%level",
                        "service": "${springAppName:-}",
                        "trace": "%X{X-B3-TraceId:-}",
                        "span": "%X{X-B3-SpanId:-}",
                        "exportable": "%X{X-Span-Export:-}",
                        "pid": "${PID:-}",
                        "thread": "%thread",
                        "class": "%logger{40}",
                        "rest": "%message"
                        }
            </pattern>
        </encoder>

        <!-- 可选项 设置时间格式 -->
        <timeFormat>yyyy-MM-dd'T'HH:mmZ</timeFormat>
        <!-- 可选项 设置时区 -->
        <!--<timeZone>Asia/Shanghai</timeZone>-->

        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
        </filter>
    </appender>
    ​
    <root level="INFO">
        <appender-ref ref="console"/>
        <!-- uncomment this to have also JSON logs -->
        <appender-ref ref="loghubAppender1"/>
        <appender-ref ref="flatfile"/>
    </root>
</configuration>

注意里面的traceid 使用的spring cloud sleuth ,引入依赖即可

chrome的hsts政策,针对.app域名,chrome强制使用https协议访问,比如:

http://hitube.app 会转换成
https://hitube.app

可以打开 chrome://net-internals/#hsts 查询 Query HSTS/PKP domain


static_sts_domain: app
static_upgrade_mode: FORCE_HTTPS
static_sts_include_subdomains: true
static_sts_observed: 1540270800
static_pkp_domain: 
static_pkp_include_subdomains: 
static_pkp_observed: 
static_spki_hashes: 
dynamic_sts_domain: hitube.app
dynamic_upgrade_mode: FORCE_HTTPS
dynamic_sts_include_subdomains: false
dynamic_sts_observed: 1542096503.341038
dynamic_sts_expiry: 1628496503.341037
dynamic_pkp_domain: 
dynamic_pkp_include_subdomains: 
dynamic_pkp_observed: 
dynamic_pkp_expiry: 
dynamic_spki_hashes: 

对于一般的域名,可以使用Delete domain security policies 删掉,但是.app 域名不可以,只能安装证书了

昨天把spring boot升级到2.1.0版本,但是报错如下


***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'dataSource', defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

查了下,原来和spring cloud版本不兼容,更改如下:


<spring-cloud.version>Finchley.SR1</spring-cloud.version>
改成
<spring-cloud.version>Greenwich.M1</spring-cloud.version>

但是spring boot 2.1 和Greenwich.M1搭配仍然有部分问题,有人建议用2.1的snapshot版本,考虑稳定性问题,我有回退到2.0.6 + Finchley.SR1 了,可以看出spring boot是用版本的第二个数字保证兼容性的。