swagger-ui在spring-cloud里无法设置basepath的坑

在springcloud里网关做的路由,隐藏了微服务的名称。
单发现无论怎么设置host和basepath都没效果,结果发现是版本的坑
用2.6.1是可以的2.7设置无效。

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>


	

springcloud中缓存的小坑坑

在springboot中使用缓存是很随意的,dao中能加缓存 service中能加缓存,crontroller中都能加缓存。
但如果把springcloud包引入后会发现缓存不能随便用了,只能在dao层中使用
别的层如果还想用缓存注解尝试过把核心库中一个jar换成早期测试版可以办到。。。但这样会让微服务间无法正常请求数据。

目前只能在dao中使用缓存
参数设置方式只能是root.args[0],root.args[0].id 这种,不能用其他的别名

Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR unknown command config

在阿里云部署springboot项目发现异常。在测试服是正常的,正式服使用了aliyun的redis服务

异常:
Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR unknown command config

应该是阿里云对redis进行了限制

需要增加:
@Configuration
public class RedisConfig {
@Bean
public static ConfigureRedisAction configureRedisAction() {
return ConfigureRedisAction.NO_OP;
}
}

传base64png图片到AliyunOSS

使用场景是想做图片裁剪,直接传oss

基本步骤:
1,图片裁剪,产生base64字符串,略
2,base64转blob
3,blob添加到表单
4,ajax上传

具体:

/**
     * 将以base64的图片url数据转换为Blob
     * @param urlData
     *            用url方式表示的base64图片数据
     */
    function convertBase64UrlToBlob(urlData){
        var bytes=window.atob(urlData.split(',')[1]);        //去掉url的头,并转换为byte
        //处理异常,将ascii码小于0的转换为大于0
        var ab = new ArrayBuffer(bytes.length);
        var ia = new Uint8Array(ab);
        for (var i = 0; i < bytes.length; i++) {
            ia[i] = bytes.charCodeAt(i);
        }
        return new Blob( [ab] , {type : 'image/png'});
    }

3添加到表单:

 var formParam = new FormData();
formParam.append("file",convertBase64UrlToBlob(base64Codes));

4,ajax提交:

$.ajax({
            type: 'POST',
            url: host ,
            data:formParam ,
...

OSS需要额外增加授权:具体参考官方例子
额外传这些参数:

 formParam.append("key",g_object_name);
        formParam.append("policy",policyBase64);
        formParam.append("OSSAccessKeyId",accessid);
        formParam.append("success_action_status",'200');
        formParam.append("signature",signature);

phabricator 无法安装在阿里云rds上

phabricator 报如下错误
Replicating Master
Database host “[数据库地址]” is configured as a master, but is replicating another host. This is dangerous and can mangle or destroy data. Only replicas should be replicating. Stop replication on the host or reconfigure Phabricator.

然后发现原因是RDS自动做了主从备份,据说还是双向,而且无法关闭。
只能从程序下手了,搜索代码发现在

switch ($ref->getReplicaStatus()) {
      case PhabricatorDatabaseRef::REPLICATION_MASTER_REPLICA:
     break;<----新增的
        $message = pht(
          'Database host "%s" is configured as a master, but is replicating '.
          'another host. This is dangerous and can mangle or destroy data. '.
          'Only replicas should be replicating. Stop replication on the '.
          'host or reconfigure Phabricator.',
 $ref->getRefKey());

https://secure.phabricator.com/source/phabricator/browse/master/src/applications/config/check/PhabricatorDatabaseSetupCheck.php;326d5bf8004ece51fbb44146766f5ddf765f1159
这个文件的174行左右判断验证了

然后我在case后直接写了个break,绕过了验证,反正是可以用了

springboot 使用druid做连接池 sql统计不显示等问题

参考 http://www.tuicool.com/articles/QRRJz2J
就是网上50%的转载帖都没写需要自己写个
public DataSource dataSource(){}
方法。不写的结果是 application.properties中的连接池配置数据都没生效!

@Component
@ConfigurationProperties(prefix = "spring.datasource")
public class DruidConfig {
    private String url;

    private String username;

    private String password;

    private String driverClassName;

    private int initialSize;

    private int maxActive;

    private int minIdle;

    private int maxWait;

    private long timeBetweenEvictionRunsMillis;

    private long minEvictableIdleTimeMillis;

    private String validationQuery;

    private boolean testWhileIdle;

    private boolean testOnBorrow;

    private boolean testOnReturn;

    private boolean poolPreparedStatements;

    private int maxPoolPreparedStatementPerConnectionSize;

    private String filters;

    public DruidConfig() {
    }

    public DruidConfig(String url, String username, String password, String driverClassName, int initialSize, int maxActive, int minIdle, int maxWait, long timeBetweenEvictionRunsMillis, long minEvictableIdleTimeMillis, String validationQuery, boolean testWhileIdle, boolean testOnBorrow, boolean testOnReturn, boolean poolPreparedStatements, int maxPoolPreparedStatementPerConnectionSize, String filters) {
        this.url = url;
        this.username = username;
        this.password = password;
        this.driverClassName = driverClassName;
        this.initialSize = initialSize;
        this.maxActive = maxActive;
        this.minIdle = minIdle;
        this.maxWait = maxWait;
        this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
        this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
        this.validationQuery = validationQuery;
        this.testWhileIdle = testWhileIdle;
        this.testOnBorrow = testOnBorrow;
        this.testOnReturn = testOnReturn;
        this.poolPreparedStatements = poolPreparedStatements;
        this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
        this.filters = filters;
    }

    @Bean
    @Primary
    public DataSource dataSource() throws Exception{
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setUrl(this.url);
        druidDataSource.setUsername(this.username);
        druidDataSource.setPassword(this.password);
        druidDataSource.setDriverClassName(this.driverClassName);
        druidDataSource.setInitialSize(this.initialSize);
        druidDataSource.setMaxActive(this.maxActive);
        druidDataSource.setMinIdle(this.minIdle);
        druidDataSource.setMaxWait(this.maxWait);
        druidDataSource.setTimeBetweenEvictionRunsMillis(this.timeBetweenEvictionRunsMillis);
        druidDataSource.setMinEvictableIdleTimeMillis(this.minEvictableIdleTimeMillis);
        druidDataSource.setValidationQuery(this.validationQuery);
        druidDataSource.setTestWhileIdle(this.testWhileIdle);
        druidDataSource.setTestOnBorrow(this.testOnBorrow);
        druidDataSource.setTestOnReturn(this.testOnReturn);
        druidDataSource.setPoolPreparedStatements(this.poolPreparedStatements);
        druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(this.maxPoolPreparedStatementPerConnectionSize);
        druidDataSource.setFilters(this.filters);
        try {
            if(null != druidDataSource) {
                druidDataSource.setFilters("wall,stat");
                druidDataSource.setUseGlobalDataSourceStat(true);
                druidDataSource.init();
            }
        } catch (Exception e) {
            throw new RuntimeException("load datasource error, dbProperties is :", e);
        }

        return druidDataSource;
    }
...set get
}

主机重置造成的面登录验证失效REMOTE HOST IDENTIFICATION HAS CHANGED!

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
2b:2c:dd:99:a8:1f:a6:e2:b1:59:0d:5d:40:04:df:21.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:4
RSA host key for videoapi3 has changed and you have requested strict checking.
Host key verification failed.

videoapi3代表主机名
简单的解决办法 :
删除/root/.ssh/known_hosts 中对应的主机记录,重新用ssh连接下就可以了

cas post跳转错误问题,post验证后重定向为get

症状是get验证没问题,post的时候会回跳到带ticket的get地址,当然本地不支持get就产生错误了。

网上可能遇到的不多,有的回答比较坑,也可能跟我的不一致,比如
acceptAnyProxy true
redirectAfterValidation false
这个答案反正我这无效。

解决办法也比较简单,其实就是每个页面都需要带个ticket
post地址也需要,只要在表单action的地址中增加参数ticket就好了
比如原来post到 http://do.action 那么就改成 http://do.action?ticket=
就好了。