实体类,方法属性操作

package com.opslab.util.bean;

import java.lang.reflect.Method;

/**
* 存放字段属性信息
*/
public class BeanStruct {

//字段的名字
private String fieldName;
//字段的类型
private Object fieldType;
//字段值读方法
private Method readMethod;
//字段值写方法
private Method writeMethod;
private boolean isDeclared;

public BeanStruct(String fieldName, Object fieldType, Method readMethod, Method writeMethod, boolean isDeclared) {
this.fieldName = fieldName;
this.fieldType = fieldType;
this.readMethod = readMethod;
this.writeMethod = writeMethod;
}

public boolean isDeclared() {
return isDeclared;
}

public void setDeclared(boolean isDeclared) {
this.isDeclared = isDeclared;
}

public String getFieldName() {
return fieldName;
}

public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}

public Object getFieldType() {
return fieldType;
}

public void setFieldType(Object fieldType) {
this.fieldType = fieldType;
}

public Method getReadMethod() {
return readMethod;
}

public void setReadMethod(Method readMethod) {
this.readMethod = readMethod;
}

public Method getWriteMethod() {
return writeMethod;
}

public void setWriteMethod(Method writeMethod) {
this.writeMethod = writeMethod;
}
}

 

package com.opslab.util.bean;

import com.opslab.helper.CollectionHelper;
import com.opslab.util.CheckUtil;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
* JavaBean相关的一些操作
*/
public class BeanUtil {

private static Map<String,BeanStruct> simpleProperties(Object obj) {
return Factory.BEAN_SIMPLE_PROPERTIES.get(obj.getClass().getName());
}

private static Map<String,BeanStruct> simplePropertiesIgnore(Object obj) {
return Factory.BEAN_SIMPLE_PROPERTIESIGNORE.get(obj.getClass().getName());
}

private static Method getReadMethod(Object obj, String pro) {
BeanStruct st = simpleProperties(obj).get(pro);
return st.getReadMethod();
}

private static Method getWriteMethod(Object obj, String pro) {
BeanStruct st = simpleProperties(obj).get(pro);
return st.getWriteMethod();
}

private static Method getReadMethodIgnore(Object obj, String pro) {
BeanStruct st = simplePropertiesIgnore(obj).get(pro);
return st.getReadMethod();
}

private static Method getWriteMethodIgnore(Object obj, String pro) {
BeanStruct st = simplePropertiesIgnore(obj).get(pro);
return st.getWriteMethod();
}

private static Object readMethod(Object bean,
Method readMethod) throws InvocationTargetException, IllegalAccessException {
return readMethod.invoke(bean);
}

private static void writeMethod(Object bean, Method writeMethod,
Object value) throws InvocationTargetException, IllegalAccessException {
writeMethod.invoke(bean, value);
}


/**
* 添加Bean到BeanFactory的解析范围中
*
* @param obj 将目标obj加入到BeanFactory的解析范围中
*/
public static void add(Object obj) {
try {
Factory.add(obj);
} catch (IntrospectionException | ClassNotFoundException e) {
e.printStackTrace();
}
}

/**
* 添加Bean到BeanFactory的解析范围中
*
* @param clazz 将目标clazz加入到BeanFactory的解析范围中
*/
public static void add(Class clazz) {
try {
Factory.add(clazz);
} catch (IntrospectionException | ClassNotFoundException e) {
e.printStackTrace();
}
}


/**
* 判断属性是否存在
*
* @param bean 判断的目标bean
* @param pro 判断的属性
* @return 是否存在
*/
public static boolean hasProperty(Object bean, String pro) {
add(bean);
Map map = simpleProperties(bean);
return map.containsKey(pro);
}


/**
* 判断自己定义的而非继承的属性pro是否存在
*
* @param bean 判断的目标bean
* @param pro 判断的属性
* @return 是否存在
*/
public static boolean hasDeclaredProperty(Object bean, String pro) {
add(bean);
Map map = simpleProperties(bean);
BeanStruct st = (BeanStruct) map.get(pro);
return CheckUtil.valid(st) && st.isDeclared();
}

/**
* 判断属性是否存在忽略大小写
*
* @param bean 判断的目标bean
* @param pro 判断的属性
* @return 是否存在
*/
public static boolean hasPropertyIgnoreCase(Object bean, String pro) {
add(bean);
Map map = simplePropertiesIgnore(bean);
return map.containsKey(pro.toLowerCase());
}


/**
* 使用自定义的过滤器
*
* @param bean 判断的目标bean
* @param pro 判断的属性
* @param filter 自定义的属性过滤函数
* @return 是否存在
*/
public static boolean hasPropertyFilter(Object bean, String pro, PropertyFilter filter) {
add(bean);
pro = filter.Properties(pro);
Map<String,BeanStruct> map = simpleProperties(bean);
if (CheckUtil.valid(map)) {
Set<String> set = map.keySet();
for (String s : set) {
if (pro.equals(filter.Properties(s))) {
return true;
}
}
}
return false;
}

/**
* 获取对象的属性
*
* @param bean 判断的目标bean
* @param pro 判断的属性
* @return 属性对应的值
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public static Object getProperty(Object bean, String pro) throws InvocationTargetException, IllegalAccessException {
add(bean);
return readMethod(bean, getReadMethod(bean, pro));
}

/**
* 获取对象的属性
*
* @param bean 操作的Bean
* @param pro 类型属性
* @return 返回属性的值如果发生异常返回空
*/
public static Object getPropertyPeaceful(Object bean, String pro) {
add(bean);
Object result = null;
try {
result = readMethod(bean, getReadMethod(bean, pro));
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
return result;
}

 


/**
* 获取对象的属性(忽略属性名字大小写)
*
* @param bean 操作的Bean
* @param pro 类型属性
* @return 返回属性的值如果发生异常返回空
*/
public static Object getPropertyIgnoreCase(Object bean,
String pro) throws InvocationTargetException, IllegalAccessException {
add(bean);
return readMethod(bean, getReadMethodIgnore(bean, pro));
}

/**
* 获取对象的属性(忽略属性名字大小写)
*
* @param bean 操作的Bean
* @param pro 类型属性
* @return 返回属性的值如果发生异常返回空
*/
public static Object getPropertyIgnoreCasePeaceful(Object bean, String pro) {
add(bean);
Object result = null;
try {
result = readMethod(bean, getReadMethodIgnore(bean, pro));
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
return result;
}

/**
* 使用自定义的过滤器获取对象的属性获取对象的属性
*
* @param bean 操作的Bean
* @param pro 类型属性
* @param filter 自定义的过滤函数
* @return 返回属性的值如果发生异常返回空
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public static Object getPropertyFilter(Object bean, String pro,
PropertyFilter filter) throws InvocationTargetException, IllegalAccessException {
add(bean);
Object result = null;
pro = filter.Properties(pro);
Map<String,BeanStruct> map = simpleProperties(bean);
if (CheckUtil.valid(map)) {
Set<String> set = map.keySet();
for (String s : set) {
if (pro.equals(filter.Properties(s))) {
result = readMethod(bean, getReadMethod(bean, s));
}
}
}
return result;
}

/**
* 使用自定义的过滤器获取对象的属性
*
* @param bean 操作的Bean
* @param pro 类型属性
* @param filter 自定义的过滤函数
* @return 返回属性的值如果发生异常返回空
*/
public static Object getPropertyFilterPeaceful(Object bean, String pro, PropertyFilter filter) {
add(bean);
Object result = null;
pro = filter.Properties(pro);
Map<String,BeanStruct> map = simpleProperties(bean);
if (CheckUtil.valid(map)) {
Set<String> set = map.keySet();
try {
for (String s : set) {
if (pro.equals(filter.Properties(s))) {
result = readMethod(bean, getReadMethod(bean, s));
}
}
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
}
return result;
}


/**
* 设置对象的属性
*
* @param bean 操作的Bean
* @param pro 类型属性
* @param value 设置属性的值
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public static void setProperty(Object bean, String pro,
Object value) throws InvocationTargetException, IllegalAccessException {
add(bean);
writeMethod(bean, getWriteMethod(bean, pro), value);
}

/**
* 设置对象的属性
*
* @param bean 操作的Bean
* @param pro 类型属性
* @param value 设置属性的值
*/
public static void setPropertyPeaceful(Object bean, String pro, Object value) {
add(bean);
try {
writeMethod(bean, getWriteMethod(bean, pro), value);
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
}

 

 

/**
* 设置对象的属性忽略大小写
*
* @param bean 操作的Bean
* @param pro 类型属性
* @param value 设置属性的值
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public static void setPropertyIgnoreCase(Object bean, String pro,
Object value) throws InvocationTargetException, IllegalAccessException {
add(bean);
writeMethod(bean, getWriteMethodIgnore(bean, pro), value);
}

/**
* 设置对象的属性忽略大小写
*
* @param bean 操作的Bean
* @param pro 类型属性
* @param value 设置属性的值
*/
public static void setPropertyIgnoreCasePeaceful(Object bean, String pro, Object value) {
add(bean);
try {
writeMethod(bean, getWriteMethodIgnore(bean, pro), value);
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
}


/**
* 使用自定义的filter进行属性设值
*
* @param bean 操作的Bean
* @param pro 类型属性
* @param value 设置属性的值
* @param filter 自定义的函数
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public static void setPropertyFilter(Object bean, String pro, Object value,
PropertyFilter filter) throws InvocationTargetException, IllegalAccessException {
add(bean);
pro = filter.Properties(pro);
Map<String,BeanStruct> map = simpleProperties(bean);
if (CheckUtil.valid(map)) {
Set<String> set = map.keySet();
for (String s : set) {
if (pro.equals(filter.Properties(s))) {
writeMethod(bean, getWriteMethodIgnore(bean, pro), value);
}
}

}
}

/**
* 使用自定义的filter进行属性设值
*
* @param bean 操作的Bean
* @param pro 类型属性
* @param value 设置属性的值
* @param filter 自定义的函数
*/
public static void setPropertyFilterPeaceful(Object bean, String pro, Object value, PropertyFilter filter) {
add(bean);
pro = filter.Properties(pro);
Map<String,BeanStruct> map = simpleProperties(bean);
if (CheckUtil.valid(map)) {
Set<String> set = map.keySet();
try {
for (String s : set) {
if (pro.equals(filter.Properties(s))) {
writeMethod(bean, getWriteMethodIgnore(bean, pro), value);
}
}
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}

}
}


/**
* 拷贝对象指定的属性
*
* @param srcBean 源Bean
* @param destBean 目标Bean
* @param pros copy的属性
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public static void copyProperty(Object srcBean, Object destBean,
String[] pros) throws InvocationTargetException, IllegalAccessException {
add(srcBean);
add(destBean);
if (CheckUtil.valid(pros)) {
for (String s : pros) {
Object value = readMethod(srcBean, getReadMethod(srcBean, s));
writeMethod(destBean, getWriteMethod(destBean, s), value);
}
}
}

/**
* 拷贝对象指定的属性
*
* @param srcBean 源Bean
* @param destBean 目标Bean
* @param pros copy的属性
*/
public static void copyPropertyPeaceful(Object srcBean, Object destBean, String[] pros) {
add(srcBean);
add(destBean);
if (CheckUtil.valid(pros)) {
try {
for (String s : pros) {
Object value =readMethod(srcBean, getReadMethod(srcBean, s));
writeMethod(destBean, getWriteMethod(destBean, s),value );
}
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
}
}

/**
* 复制同名属性
*
* @param srcBean 源Bean
* @param destBean 目标Bean
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public static void copyProperties(Object srcBean,
Object destBean) throws InvocationTargetException, IllegalAccessException {
add(srcBean);
add(destBean);
Map<String,BeanStruct> srcMap = simpleProperties(srcBean);
Map<String,BeanStruct> dstMap = simpleProperties(destBean);
Map<String,BeanStruct> intersection = CollectionHelper.intersection(srcMap, dstMap);
for (Map.Entry<String,BeanStruct> entry : intersection.entrySet()) {
String key = entry.getKey();
Object value = readMethod(srcBean, getReadMethod(srcBean, key));
writeMethod(destBean, getWriteMethod(destBean, key), value);
}
}

/**
* 复制同名属性
*
* @param srcBean 源Bean
* @param destBean 目标Bean
*/
public static void copyPropertiesPeaceful(Object srcBean, Object destBean) {
add(srcBean);
add(destBean);
Map<String,BeanStruct> srcMap = simpleProperties(srcBean);
Map<String,BeanStruct> dstMap = simpleProperties(destBean);
Map<String,BeanStruct> intersection = CollectionHelper.intersection(srcMap, dstMap);
for (Map.Entry<String,BeanStruct> entry : intersection.entrySet()) {
String key = entry.getKey();
try{
//为什么会将try写在里面而不是foreach的外面?
//如果你想尽可能多的复制属性的话你可以
Object value = readMethod(srcBean, getReadMethod(srcBean, key));
writeMethod(destBean, getWriteMethod(destBean, key), value);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}

/**
* 复制同名属性(忽略大小写)
*
* @param srcBean 原Bean
* @param destBean 目标Bean
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public static void copyPropertiesIgnoreCase(Object srcBean,
Object destBean) throws InvocationTargetException, IllegalAccessException {
add(srcBean);
add(destBean);
Map<String,BeanStruct> srcMap = simplePropertiesIgnore(srcBean);
Map<String,BeanStruct> dstMap = simplePropertiesIgnore(destBean);
Map<String,BeanStruct> intersection = CollectionHelper.intersection(srcMap, dstMap);
for (Map.Entry entry : intersection.entrySet()) {
String key = (String) entry.getKey();
Object value = readMethod(srcBean, getReadMethodIgnore(srcBean, key));
writeMethod(destBean, getWriteMethodIgnore(destBean, key), value);
}
}

/**
* 复制同名属性(忽略大小写)
*
* @param srcBean 原Bean
* @param destBean 目标Bean
*/
public static void copyPropertiesIgnoreCasePeaceful(Object srcBean, Object destBean) {
add(srcBean);
add(destBean);
Map<String,BeanStruct> srcMap = simplePropertiesIgnore(srcBean);
Map<String,BeanStruct> dstMap = simplePropertiesIgnore(destBean);
Map<String,BeanStruct> intersection = CollectionHelper.intersection(srcMap, dstMap);
for (Map.Entry entry : intersection.entrySet()) {
String key = (String) entry.getKey();
Object value = null;
try {
value = readMethod(srcBean, getReadMethodIgnore(srcBean, key));
writeMethod(destBean, getWriteMethodIgnore(destBean, key), value);
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}

}
}


/**
* 使用自定义的属性过滤函数
*
* @param srcBean 原Bean
* @param destBean 目标bean
* @param filter 自定义的过滤函数
* @throws InvocationTargetException
* @throws IllegalAccessException
*/
public static void copyProperties(Object srcBean, Object destBean,
PropertyFilter filter) throws InvocationTargetException, IllegalAccessException {
add(srcBean);
add(destBean);
Map<String,BeanStruct> srcMap = simpleProperties(srcBean);
Map<String,BeanStruct> dstMap = simpleProperties(destBean);
if (CheckUtil.valid(srcMap, dstMap)) {
Map<String,String> srcMapFilter = new HashMap<>();
Map<String,String> dstMapFilter = new HashMap<>();
for (Map.Entry<String,BeanStruct> entry : srcMap.entrySet()) {
srcMapFilter.put(filter.Properties(entry.getKey()), entry.getKey());
}
for (Map.Entry<String,BeanStruct> entry : dstMap.entrySet()) {
dstMapFilter.put(filter.Properties(entry.getKey()), entry.getKey());
}
Map<String,String> intersection = CollectionHelper.intersection(srcMapFilter, dstMapFilter);
if (CheckUtil.valid(intersection)) {
for (Map.Entry<String,String> entry : intersection.entrySet()) {
String key = entry.getKey();
String srcKey = srcMapFilter.get(key);
String dstKey = dstMapFilter.get(key);
Object value = readMethod(srcBean, getReadMethod(srcBean, srcKey));
writeMethod(destBean, getWriteMethod(destBean, dstKey), value);
}
}
}
}

/**
* 使用自定义的属性过滤函数
*
* @param srcBean 原Bean
* @param destBean 目标bean
* @param filter 自定义的过滤函数
*/
public static void copyPropertiesPeaceful(Object srcBean, Object destBean, PropertyFilter filter) {
add(srcBean);
add(destBean);
Map<String,BeanStruct> srcMap = simpleProperties(srcBean);
Map<String,BeanStruct> dstMap = simpleProperties(destBean);
if (CheckUtil.valid(srcMap, dstMap)) {
Map<String,String> srcMapFilter = new HashMap<>();
Map<String,String> dstMapFilter = new HashMap<>();
for (Map.Entry<String,BeanStruct> entry : srcMap.entrySet()) {
srcMapFilter.put(filter.Properties(entry.getKey()), entry.getKey());
}
for (Map.Entry<String,BeanStruct> entry : dstMap.entrySet()) {
dstMapFilter.put(filter.Properties(entry.getKey()), entry.getKey());
}
Map<String,String> intersection = CollectionHelper.intersection(srcMapFilter, dstMapFilter);
if (CheckUtil.valid(intersection)) {
for (Map.Entry<String,String> entry : intersection.entrySet()) {
String key = entry.getKey();
String srcKey = srcMapFilter.get(key);
String dstKey = dstMapFilter.get(key);
try {
Object value = readMethod(srcBean, getReadMethod(srcBean, srcKey));
writeMethod(destBean, getWriteMethod(destBean, dstKey), value);
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}

}
}
}
}
}

 

package com.opslab.util.bean;

import com.opslab.util.CheckUtil;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Hashtable;
import java.util.Map;

/**
* 提供一些BeanUti需要的方法
*/
public class Factory {


/**
* 存放BeanUtil解析过的JavaBean数据
* 只获取简单的属性字段
*/
public static Map<String,Map<String,BeanStruct>> BEAN_SIMPLE_PROPERTIES = new Hashtable<>();


/**
* 存放BeanUtil解析过的JavaBean数据
* 只获取简单的属性字段(忽略字段名字的大小写)
*/
public static Map<String,Map<String,BeanStruct>> BEAN_SIMPLE_PROPERTIESIGNORE = new Hashtable<>();


static {
//可以实现实现明确的JavaBean的配置
}

public static boolean isDeclaredField(String className, String pro) throws ClassNotFoundException {
Class classz = Class.forName(className);
Field[] fields = classz.getFields();
if (CheckUtil.valid(fields)) {
for (Field f : fields) {
if (f.getName().equals(pro)) {
return false;
}
}
}
return true;
}


/**
* 将JavaBean进行解析并存在在static变量中
*
* @param obj
*/
public static void add(Object obj) throws IntrospectionException, ClassNotFoundException {
add(obj.getClass());
}


public static void add(Class clazz) throws IntrospectionException, ClassNotFoundException {
String className = clazz.getName();
if (!CheckUtil.valid(BEAN_SIMPLE_PROPERTIES.get(className))) {
BeanInfo beanInfo = Introspector.getBeanInfo(clazz);
PropertyDescriptor[] proDescrtptors = beanInfo.getPropertyDescriptors();
if (proDescrtptors != null && proDescrtptors.length > 0) {
Map<String,BeanStruct> simpleProperties = new Hashtable<>();
Map<String,BeanStruct> simplePropertiesIgnore = new Hashtable<>();
for (PropertyDescriptor propDesc : proDescrtptors) {
String fieldName = propDesc.getName();
if (!"class".equals(fieldName)) {
Object type = propDesc.getPropertyType();
Method readMethod = propDesc.getReadMethod();
Method writeMethod = propDesc.getWriteMethod();
boolean isDeclared = isDeclaredField(className, fieldName);
simpleProperties.put(fieldName, new BeanStruct(fieldName, type, readMethod, writeMethod, isDeclared));
simplePropertiesIgnore.put(fieldName.toLowerCase(), new BeanStruct(fieldName, type, readMethod, writeMethod, isDeclared));
}
}
BEAN_SIMPLE_PROPERTIES.put(className, simpleProperties);
BEAN_SIMPLE_PROPERTIESIGNORE.put(className, simplePropertiesIgnore);
}
}
}

}

 

package com.opslab.util.bean;

/**
* 属性过滤接口
*/
public interface PropertyFilter {
public String Properties(String pro);
}

 

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.0opslab</groupId>
<artifactId>opslabJutil</artifactId>
<version>2.0.1</version>

<name>opslabJutil</name>
<description>Simple and convenient to use it to accomplish common development java code</description>
<url>https://github.com/0opslab/opslabJutil</url>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<developers>
<developer>
<name>devopslab</name>
<email>438558488@qq.com</email>
<url>http://0opslab.com/</url>
</developer>
</developers>

<scm>
<connection>scm:git:https://github.com/0opslab/utils</connection>
<developerConnection>scm:git:https://github.com/0opslab/utils</developerConnection>
<url>https://github.com/0opslab/utils</url>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!--pinyin4j-->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
</dependency>
<!--apache-commons-net-->
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<!--hamcrest-core-->
<!--
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
</dependency>
-->
<!--java-mail-->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>

<!--cpdetector-->
<!--
<dependency>
<groupId>org.mozilla.intl</groupId>
<artifactId>chardet</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>cpdetector</groupId>
<artifactId>cpdetector</artifactId>
<version>1.04</version>
</dependency>
-->
<dependency>
<groupId>net.sourceforge.jchardet</groupId>
<artifactId>jchardet</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>


<!--<profiles>-->
<!--<profile>-->
<!--<id>release</id>-->
<!--<build>-->
<!--<plugins>-->
<!--<plugin>-->
<!--<groupId>org.sonatype.plugins</groupId>-->
<!--<artifactId>nexus-staging-maven-plugin</artifactId>-->
<!--<version>1.6.3</version>-->
<!--<extensions>true</extensions>-->
<!--<configuration>-->
<!--<serverId>oss</serverId>-->
<!--<nexusUrl>https://oss.sonatype.org/</nexusUrl>-->
<!--<autoReleaseAfterClose>true</autoReleaseAfterClose>-->
<!--</configuration>-->
<!--</plugin>-->
<!--&lt;!&ndash; Source &ndash;&gt;-->
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-source-plugin</artifactId>-->
<!--<version>2.2.1</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<phase>package</phase>-->
<!--<goals>-->
<!--<goal>jar-no-fork</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
<!--&lt;!&ndash; Javadoc &ndash;&gt;-->
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-javadoc-plugin</artifactId>-->
<!--<version>2.9.1</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<phase>package</phase>-->
<!--<goals>-->
<!--<goal>jar</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
<!--&lt;!&ndash; GPG &ndash;&gt;-->
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-gpg-plugin</artifactId>-->
<!--<version>1.5</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<phase>verify</phase>-->
<!--<goals>-->
<!--<goal>sign</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
<!--</plugins>-->
<!--</build>-->
<!--<distributionManagement>-->
<!--<snapshotRepository>-->
<!--<id>oss</id>-->
<!--<url>http://oss.sonatype.org/content/repositories/snapshots</url>-->
<!--</snapshotRepository>-->
<!--<repository>-->
<!--<id>oss</id>-->
<!--<url>http://oss.sonatype.org/service/local/staging/deploy/maven2/</url>-->
<!--</repository>-->
<!--</distributionManagement>-->
<!--</profile>-->
<!--</profiles>-->

 

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
<includes>
<include>**/*Test.java</include>
</includes>
<excludes>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

 

 

hubgit地址:https://github.com/0opslab/opslabJutil

posted on 2019-01-11 14:20  我是司  阅读(654)  评论(0)    收藏  举报

导航