Часто используемые инструменты: сборник
package com.hm.car.util;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import com.hm.common.ServerResponse;
/**
* @author shishun.wang
* @date 2016年12月15日 下午12:00:07
* @version 1.0
* @describe
*/
public class ControllerResult<T> {
public static <T> ResponseEntity<ServerResponse<T>> success(T result) {
return new ResponseEntity<ServerResponse<T>>(new ServerResponse<T>().success(result), HttpStatus.OK);
}
public static <T> ResponseEntity<ServerResponse<T>> failed(String message) {
return new ResponseEntity<ServerResponse<T>>(new ServerResponse<T>().failure(message), HttpStatus.BAD_REQUEST);
}
public static <T> ResponseEntity<ServerResponse<T>> failed(Exception e) {
return new ResponseEntity<ServerResponse<T>>(new ServerResponse<T>().failure(e.getMessage()),
HttpStatus.BAD_REQUEST);
}
}
package com.hm.car.util;
import java.lang.reflect.Field;
import java.util.Arrays;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ReflectionUtils;
import com.hm.common.util.CommonUtil;
/**
* @author shishun.wang
* @date 2016年12月14日 上午10:11:15
* @version 1.0
* @describe
*/
public class BeanUtil {
private static final String MODEL_ID_FIELD = "id";
public static final void copyProperties(Object source, Object target, String... ignoreProperties) {
if (com.hm.common.util.CommonUtil.isAnyEmpty(source, target)) {
return;
}
BeanUtils.copyProperties(source, target, ignoreProperties);
// Trying copy id field
if (com.hm.common.util.CommonUtil.isNotEmpty(ignoreProperties) && Arrays.asList(ignoreProperties).contains(MODEL_ID_FIELD)) {
return;
}
Field targetFiled = ReflectionUtils.findField(target.getClass(), MODEL_ID_FIELD, String.class);
if (targetFiled == null) {
return;
}
Field sourceFiled = ReflectionUtils.findField(source.getClass(), MODEL_ID_FIELD);
if (sourceFiled == null) {
return;
}
try {
sourceFiled.setAccessible(true);
Object sourceId = sourceFiled.get(source);
if (sourceId == null) {
return;
}
targetFiled.setAccessible(true);
if (sourceId instanceof String) {
ReflectionUtils.setField(targetFiled, target, sourceId);
} else {
ReflectionUtils.setField(targetFiled, target, sourceId.toString());
}
} catch (IllegalArgumentException | IllegalAccessException e) {
LoggerFactory.getLogger(CommonUtil.class).error("Failed to reflect set id properties", e);
}
}
}
<?xml version="1.0" encoding="UTF-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">
<pluginGroups>
</pluginGroups>
<proxies></proxies>
<servers>
<server>
<id>nexus-releases</id>
<username>deployment</username>
<password>1234567</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>deployment</username>
<password>1234567</password>
</server>
<server>
<id>hm-snapshots</id>
<username>admin</username>
<password>1234567</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus-snapshots</id>
<mirrorOf>nexus-snapshots</mirrorOf>
<url>http://192.168.3.100:8888/nexus/content/groups/public-snapshots</url>
</mirror>
<mirror>
<id>nexus-releases</id>
<mirrorOf>nexus-releases</mirrorOf>
<url>http://192.168.3.100:8888/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>hm-snapshots</id>
``` ```
<releases><enabled>false</enabled></releases>
</pluginRepository>
<pluginRepository>
<id>hm-snapshots</id>
<name>hm-snapshots</name>
<url>http://120.92.147.60:8081/nexus/content/repositories/hm-snapshots</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</pluginRepository>
<pluginRepository>
<id>thirdparty</id>
<name>thirdparty</name>
<url>http://120.92.147.60:8081/nexus/content/repositories/thirdparty</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!---->
</settings>
В этом тексте описывается конфигурация репозиториев плагинов в системе сборки Maven. В нём определяются два репозитория: «hm-snapshots» и «thirdparty». Для каждого из них указываются идентификатор, имя, URL-адрес и настройки включения снимков (snapshots) и релизов (releases).
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Комментарии ( 0 )