2017七月30
public void newFile(File file){
try {
if (file.createNewFile()) {
System.out.println("文件创建成功!");
} else {
String cName = changeName(file);
File files = new File("." + File.separator + cName);
newFile(files);
}
} catch (IOException e) {
e.printStackTrace();
}
}
public String changeName(File file) {
String name = file.getName();
int index = name.lastIndexOf('.');
int index2 = name.lastIndexOf("_副本");
if (index2 < 0) {
return name.substring(0, index) + "_副本1" + name.substring(index);
} else {
String num = name.substring(index2+3, index);
int i = Integer.valueOf(num)+1;
return name.substring(0, index2) + "_副本" + i + name.substring(index);
}
}
2017三月23
1、wx_config 实体类添加三个字段,对应的表结构也要手动修改:
@Column
@Comment("access_token")
@ColDefine(type = ColType.VARCHAR, width = 255)
private String access_token;
@Column
@Comment("access_token_expires")
@ColDefine(type = ColType.INT)
private Integer access_token_expires;
@Column
@Comment("access_token_lastat")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String access_token_lastat;
get set ...方法生成出来
2、nutzwx版本升级为1.r.61-SNAPSHOT
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzwx</artifactId>
<version>1.r.61-SNAPSHOT</version>
</dependency>
3、nutz版本升级为1.r.60
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz</artifactId>
<version>1.r.60</version>
</dependency>
4、WxConfigService 类getWxApi2替换为如下代码(主要是DaoAccessTokenStore从数据库取access_token)
public WxApi2 getWxApi2(String wxid) {
Wx_config appInfo = this.fetch(Cnd.where("id", "=", wxid));
DaoAccessTokenStore myDaoAccessTokenStore = new DaoAccessTokenStore(dao());
Map<String, Object> params = new HashMap<>();
params.put("id", appInfo.getId());
myDaoAccessTokenStore.setTableAccessToken("access_token");
myDaoAccessTokenStore.setTableAccessTokenExpires("access_token_expires");
myDaoAccessTokenStore.setTableAccessTokenLastat("access_token_lastat");
myDaoAccessTokenStore.setFetch("select access_token,access_token_expires,access_token_lastat from wx_config where id=@id");
myDaoAccessTokenStore.setUpdate("update wx_config set access_token=@access_token, access_token_expires=@access_token_expires, access_token_lastat=@access_token_lastat where id=@id");
myDaoAccessTokenStore.setParams(params);
WxApi2Impl wxApi2 = new WxApi2Impl();
wxApi2.setAppid(appInfo.getAppid());
wxApi2.setAppsecret(appInfo.getAppsecret());
wxApi2.setEncodingAesKey(appInfo.getEncodingAESKey());
wxApi2.setToken(appInfo.getToken());
wxApi2.setAccessTokenStore(myDaoAccessTokenStore);
return wxApi2;
}
2017三月17
pom.xml
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.logback-extensions</groupId>
<artifactId>logback-ext-spring</artifactId>
<version>0.1.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.25</version>
</dependency>
排除其他包的log4j引用,特别是dubbo的、shiro的
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.8.4</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>1.3.2</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>1.3.2</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<!-- For assistance related to logback-translator or configuration -->
<!-- files in general, please contact the logback user mailing list -->
<!-- at http://www.qos.ch/mailman/listinfo/logback-user -->
<!-- -->
<!-- For professional support please see -->
<!-- http://www.qos.ch/shop/products/professionalSupport -->
<!-- -->
<configuration>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<file>/monitor.log</file>
<!-- Policy定义如何滚动,按文件大小滚动生成日志 -->
<!-- 如果是按文件大小滚动生成日志,前面的file标签可省略,而使用fileNamePattern标签定义的名字 -->
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>/monitor.%i.log.gz
</fileNamePattern>
<!-- 归档日志的下标,替换fileNamePattern的%i,最多3个归档文件 -->
<minIndex>1</minIndex>
<maxIndex>5</maxIndex>
</rollingPolicy>
<!-- triggeringPolicy定义什么时候滚动,下面是定义了文件大小超过100M的时候产生归档文件 -->
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>300MB</maxFileSize>
</triggeringPolicy>
<!-- append是否接着上次写文件结尾继续写,默认为true -->
<append>true</append>
<encoding>GBK</encoding>
<!-- layout,定义格式 -->
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>[%-5level] %d{HH:mm:ss.SSS} [%thread] %logger %caller{2} - %msg%n</pattern>
</layout>
</appender>
<logger name="org.springframework" level="info"/>
<logger name="org.nutz.dao" level="debug"/>
<logger name="net.sf.ehcache" level="info"/>
<logger name="druid.sql" level="info"/>
<logger name="com.alibaba.druid" level="info"/>
<logger name="org.apache.shiro" level="info"/>
<logger name="org.quartz" level="info"/>
<root level="debug">
<appender-ref ref="Console"/>
</root>
</configuration>
2016十二月8
Cnd cnd = Cnd.NEW();
if (!Strings.isBlank(src)) {
cnd.and("srcFrom", "=", src);
}
if (!Strings.isBlank(name)) {
String[] n = StringUtils.split(name, " ");
SqlExpressionGroup group = new SqlExpressionGroup();
for (String s : n) {
SqlExpression sqlExpression = Cnd.exp("srcName", "like", "%" + s + "%");
group.or(sqlExpression);
}
cnd.and(group);
}
cnd.and(Cnd.exps("productSku", "=", "").or("productSku", "is", null));
2016十一月28
elasticsearch 5.0/5.0.1以上版本的elasticsearch-head插件,使用node单独运行,会出现跨站访问的问题:
http://localhost:9200/_nodes. No 'Access-Control-Allow-Origin'
header is present on the requested resource.
Origin 'http://localhost:9100' is therefore not allowed access.
elasticsearch-head 安装教程如下:
1、安装node;
2、下载elasticsearch-head,安装node组件:
>git clone git://github.com/mobz/elasticsearch-head.git
>cd elasticsearch-head
>npm i
>npm i grunt-cli -g
>grunt server
3、elasticsearch.yml 增加配置项
http.cors.enabled: true
http.cors.allow-origin: /http?:\/\/127.0.0.1(:[0-9]+)?/
4、Gruntfile.js 增加hostname配置项
connect: {
server: {
options: {
port: 9100,
hostname: '*',
base: '.',
keepalive: true
}
}
}
5、修改配置文件后各自重启
http://127.0.0.1:9100/ 访问即可(http.cors.allow-origin 里配的是127.0.0.1哦)
2016十月20
Shop_goods_type obj = shopGoodsTypeService.fetch(id);
shopGoodsTypeService.fetchLinks(obj, null, Cnd.orderBy().asc("location"));
for (Shop_goods_type_props o : obj.getPropsList()) {
shopGoodsTypeService.dao().fetchLinks(o, null, Cnd.orderBy().asc("location"));
}
2016九月12
webpack.base.conf.js
vue-html 注释掉
// {
// test: /\.html$/,
// loader: 'vue-html'
// },
2016八月19
server {
listen 80;
listen 443 ssl;
if ( $scheme = "http" ) {
rewrite ^(.*) https://$host$1;
}
server_name nutzwk.wizzer.cn;
root "/java/work/nutzwk";
ssl_certificate /java/work/1_nutzwk.wizzer.cn_bundle.crt;
ssl_certificate_key /java/work/2_nutzwk.wizzer.cn.key;
add_header "X-UA-Compatible" "IE=Edge, chrome=1";
location / {
proxy_pass http://127.0.0.1:9091;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
2016八月16
List<BasicNameValuePair> formParams = new ArrayList<>();
formParams.add(new BasicNameValuePair("urlpp", ""));
formParams.add(new BasicNameValuePair("urlkm", ""));
formParams.add(new BasicNameValuePair("khjb", "2"));
HttpEntity httpEntity = new UrlEncodedFormEntity(formParams, "UTF-8");
HttpPost httpPost = new HttpPost(tesseract.njwztx_baseUrl + "fetchNextList.action");
httpPost.setEntity(httpEntity);
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
httpPost.setHeader("X-Requested-With", "XMLHttpRequest");
httpPost.setHeader("Cookie", "rememberPhone=1; phoneNumber=" + tesseract.getNjwztx_dhhm() + "; friendlyReminder=true;JSESSIONID=" + JSESSIONID + ";");
HttpClient httpclient = HttpClients.createDefault();
HttpResponse response = httpclient.execute(httpPost);
HttpEntity entity = response.getEntity();
Header[] headers = response.getAllHeaders();
for (int i = 0; i < headers.length; i++) {
log.debug("header" + i + ":::" + headers[i]);
}
if (entity != null) {
log.debug("getContentEncoding:::" + entity.getContentEncoding());
log.debug("getContentType:::" + entity.getContentType());
String str = EntityUtils.toString(response.getEntity());
log.debug(str);
Files.write("2.html", str);
}
2016七月25
C:\Windows\System32\drivers\etc\hosts
151.101.24.215 repo.maven.apache.org