最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java核心技術(shù)之反射

 更新時(shí)間:2021年11月10日 15:12:45   作者:程序研  
本文非常詳細(xì)的講解了java反射的相關(guān)資料,java反射在現(xiàn)今的使用中很頻繁,希望此文可以幫大家解答疑惑,可以幫助大家理解

一、Class類與Java反射

Class textFieldC=tetxField.getClass(); //tetxField為JTextField類對(duì)象

反射可訪問的主要描述

1、訪問構(gòu)造方法

每個(gè)Constructor對(duì)象代表一個(gè)構(gòu)造方法,利用Constructor對(duì)象可以操縱相應(yīng)的構(gòu)造方法。

  • getConstructors() //獲取公有
  • getConstructor(Class<?>... parameterTypes) //獲取指定公有
  • getDeclaredConstructors() //獲取所有
  • getDeclaredConstructor(Class<?>... parameterTypes) //獲取指定方法

創(chuàng)建Demo1類,聲明String類型成員變量和3個(gè)int類型成員變量,并提供3個(gè)構(gòu)造方法。

package bao;
 public class Demo1{
 	String s;
	int i,i2,i3;
	private Demo1() {
 	}
		protected Demo1(String s,int i) {
			this.s=s;
			this.i=i;
		}
		public Demo1(String... strings)throws NumberFormatException{
			if(0<strings.length) {
				i=Integer.valueOf(strings[0]);
			}
			if(1<strings.length) {
				i2=Integer.valueOf(strings[0]);
			}
			if(2<strings.length) {
				i3=Integer.valueOf(strings[0]);
			}
		}
 		public  void print() {
			System.out.println("s="+s);
			System.out.println("i="+i);
			System.out.println("i2="+i2);
			System.out.println("i3="+i3);
		}
 }

編寫Main類,在該類對(duì)Demo1進(jìn)行反射訪問的所有構(gòu)造方法,并將該構(gòu)造方法是否允許帶有可變數(shù)量的參數(shù)、入口參數(shù)和可能拋出的異常類型信息輸出。

package bao;
 import java.lang.reflect.Constructor;
 public class Main {
	public static void main(String[] args) {
		Demo1 demo=new Demo1("10","20","30");
		Class<? extends Demo1>demoC=demo.getClass();  
		//獲得所有構(gòu)造方法
		Constructor[] declaredConstryctors=demoC.getDeclaredConstructors();
		for(int i=0;i<declaredConstryctors.length;i++) {
			Constructor<?> constructor=declaredConstryctors[i];
			System.out.println("查看是否允許帶有可變數(shù)量的參數(shù):"+constructor.isVarArgs());
			System.out.println("該構(gòu)造方法的入口參數(shù)類型依次為:");
			Class[]parameterTypes=constructor.getParameterTypes();      //獲取所有參數(shù)類型
			for(int j=0;j<parameterTypes.length;j++) {
				System.out.println(" "+parameterTypes[j]);
			}
			System.out.println("該構(gòu)造方法的入口可能拋出異常類型為:");
			//獲取所有可能拋出的異常信息類型
			Class[] exceptionTypes=constructor.getExceptionTypes();
			for(int j=0;j<exceptionTypes.length;j++) {
				System.out.println(" "+exceptionTypes[j]);
			}
			Demo1 example2=null;
			while(example2==null) {
				try {           
					if(i==2) {
						example2=(Demo1)constructor.newInstance();
				}else if(i==1) {
					example2=(Demo1)constructor.newInstance("7",5);
				}else {
					Object[] parameters=new Object[] {new String[] {"100","200","300"}};
					example2=(Demo1)constructor.newInstance(parameters);		
				}	
				}catch(Exception e){
				System.out.println("在創(chuàng)建對(duì)象時(shí)拋出異常,下面執(zhí)行setAccessible()方法");
				constructor.setAccessible(true);     //設(shè)置允許訪問
				}
			}
			if(example2!=null) {
				example2.print();
				System.out.println();
			}
		}
 	}
}
  /*輸出結(jié)果:
 查看是否允許帶有可變數(shù)量的參數(shù):true
該構(gòu)造方法的入口參數(shù)類型依次為:
 class [Ljava.lang.String;
該構(gòu)造方法的入口可能拋出異常類型為:
 class java.lang.NumberFormatException
s=null
i=100
i2=100
i3=100
查看是否允許帶有可變數(shù)量的參數(shù):false
該構(gòu)造方法的入口參數(shù)類型依次為:
 class java.lang.String
 int
該構(gòu)造方法的入口可能拋出異常類型為:
s=7
i=5
i2=0
i3=0
查看是否允許帶有可變數(shù)量的參數(shù):false
該構(gòu)造方法的入口參數(shù)類型依次為:
該構(gòu)造方法的入口可能拋出異常類型為:
在創(chuàng)建對(duì)象時(shí)拋出異常,下面執(zhí)行setAccessible()方法
s=null
i=0
i2=0
i3=0
 */

2、訪問成員變量

每個(gè)Field對(duì)象代表一個(gè)成員變量,利用Field對(duì)象可以操縱相應(yīng)的成員變量。

  • getFields()
  • getField(String name)
  • getDeclaredFields()
  • getDeclaredField(String name)

創(chuàng)建Demo1類依次聲明int、fioat、boolean和String類型的成員變量,并設(shè)置不同的訪問權(quán)。

package bao;
 public class Demo1{
	int i;
	public float f;
	protected boolean b;
	private String s;
}
 

通過反射訪問Demo1類中的所有成員變量,將成成員變量的名稱和類型信息輸出。

package bao;
 import java.lang.reflect.Field;
public class Main {
	public static void main(String[] args) {
		Demo1 demo=new Demo1();
		Class demoC=demo.getClass();
		//獲得所有成員變量
		Field[] declaredField=demoC.getDeclaredFields();
		for(int i=0;i<declaredField.length;i++) {
			Field field=declaredField[i];
			System.out.println("名稱為:"+field.getName());   //獲取成員變量名稱
 			Class fieldType=field.getType();   ///獲取成員變量類型
			System.out.println("類型為:"+fieldType);
			boolean isTurn=true;
			while(isTurn) {
				try {
					isTurn=false;
					System.out.println("修改前的值為:"+field.get(demo));
					if(fieldType.equals(int.class)) {     //判斷成員變量的類型是否為int類型
						System.out.println("利用方法setInt()修改成員變量的值");
						field.setInt(demo, 168);      //為int類型成員變量賦值
					}else if(fieldType.equals(float.class)){     //判斷成員變量的類型是否為float類型
						System.out.println("利用方法 setFloat()修改成員變量的值");      
						field.setFloat(demo, 99.9F);      //為float類型成員變量賦值
					}else if(fieldType.equals(boolean.class)){      //判斷成員變量的類型是否為boolean類型
						System.out.println("利用方法 setBoolean()修改成員變量的值");
						field.setBoolean(demo, true);      //為boolean類型成員變量賦值
					}else {
						System.out.println("利用方法 set()修改成員變量的值");
						field.set(demo, "MWQ");            //可以為各種類型的成員變量賦值
					}
					//獲得成員變量值
					System.out.println("修改后的值為:"+field.get(demo));
				}catch(Exception e) {
					System.out.println("在設(shè)置成員變量值時(shí)拋出異常,"+"下面執(zhí)行setAccesssible()方法!");
 					field.setAccessible(true);       //設(shè)置為允許訪問
					isTurn=true;
				}
			}
			System.out.println();
		}
	}
}
  

/*輸出結(jié)果:
名稱為:i
類型為:int
修改前的值為:0
利用方法setInt()修改成員變量的值
修改后的值為:168
名稱為:f
類型為:float
修改前的值為:0.0
利用方法 setFloat()修改成員變量的值
修改后的值為:99.9
名稱為:b
類型為:boolean
修改前的值為:false
利用方法 setBoolean()修改成員變量的值
修改后的值為:true
名稱為:s
類型為:class java.lang.String
在設(shè)置成員變量值時(shí)拋出異常,下面執(zhí)行setAccesssible()方法!
修改前的值為:null
利用方法 set()修改成員變量的值
修改后的值為:MWQ
*/

3、訪問方法

每個(gè)Method對(duì)象代表一個(gè)方法,利用Method對(duì)象可以操縱相應(yīng)的方法。

  • getMethods()
  • getMethod(String name, Class<?>... parameterTypes)
  • getDeclaredMethods()
  • getDeclaredMethod(String name, Class<?>... parameterTypes)

創(chuàng)建Demo1類,編寫4個(gè)典型方法。

package bao;
 public class Demo1{
    static void staitcMethod() {
    	System.out.println("執(zhí)行staitcMethod()方法");
    }
    public int publicMethod(int i) {
    	System.out.println("執(zhí)行publicMethod()方法");
    	return i*100;
    }
    protected int protectedMethod(String s,int i)throws NumberFormatException {
    	System.out.println("執(zhí)行protectedMethod()方法");
    	return Integer.valueOf(s)+i;
    }
    private String privateMethod(String...strings) {
    	System.out.println("執(zhí)行privateMethod()方法");
    	StringBuffer stringBuffer=new StringBuffer();
    	for(int i=0;i<stringBuffer.length();i++) {
    		stringBuffer.append(strings[i]);
    	}
    	return stringBuffer.toString();
    }
 }
 

反射訪問Demm1類中的所有方法,將方法的名稱、入口參數(shù)類型、返回值類型等信息輸出

package bao;
 import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class Main {
	public static void main(String[] args) {
	Demo1 demo = new Demo1();
	Class demoC = demo.getClass();
	// 獲得所有方法
	Method[] declaredMethods = demoC.getDeclaredMethods();
	for (int i = 0; i < declaredMethods.length; i++) {
		Method method = declaredMethods[i]; // 遍歷方法
		System.out.println("名稱為:" + method.getName()); // 獲得方法名稱
		System.out.println("是否允許帶有可變數(shù)量的參數(shù):" + method.isVarArgs());
		System.out.println("入口參數(shù)類型依次為:");
		// 獲得所有參數(shù)類型
		Class[] parameterTypes = method.getParameterTypes();
		for (int j = 0; j < parameterTypes.length; j++) {
			System.out.println(" " + parameterTypes[j]);
		}
		// 獲得方法返回值類型
		System.out.println("返回值類型為:" + method.getReturnType());
		System.out.println("可能拋出的異常類型有:");
		// 獲得方法可能拋出的所有異常類型
		Class[] exceptionTypes = method.getExceptionTypes();
		for (int j = 0; j < exceptionTypes.length; j++) {
			System.out.println(" " + exceptionTypes[j]);
		}
		boolean isTurn = true;
		while (isTurn) {
			try {
				isTurn = false;
				if("staitcMethod".equals(method.getName())) {
					method.invoke(demo);                         // 執(zhí)行沒有入口參數(shù)的方法
				}else if("publicMethod".equals(method.getName())) {
					System.out.println("返回值為:"+ method.invoke(demo, 168)); // 執(zhí)行方法
				}else if("protectedMethod".equals(method.getName())) {
					System.out.println("返回值為:"+ method.invoke(demo, "7", 5)); // 執(zhí)行方法
				}else {
					Object[] parameters = new Object[] { new String[] {"M", "W", "Q" } }; // 定義二維數(shù)組
					System.out.println("返回值為:"+ method.invoke(demo, parameters));
				}
			}catch(Exception e) {
				System.out.println("在執(zhí)行方法時(shí)拋出異常,"
						+ "下面執(zhí)行setAccessible()方法!");
				method.setAccessible(true); // 設(shè)置為允許訪問
				isTurn = true;
			}
		}
		System.out.println();
	}
	}
}
  

/*輸出結(jié)果:
名稱為:publicMethod
是否允許帶有可變數(shù)量的參數(shù):false
入口參數(shù)類型依次為:
int
返回值類型為:int
可能拋出的異常類型有:
執(zhí)行publicMethod()方法
返回值為:16800
名稱為:staitcMethod
是否允許帶有可變數(shù)量的參數(shù):false
入口參數(shù)類型依次為:
返回值類型為:void
可能拋出的異常類型有:
執(zhí)行staitcMethod()方法
名稱為:protectedMethod
是否允許帶有可變數(shù)量的參數(shù):false
入口參數(shù)類型依次為:
class java.lang.String
int
返回值類型為:int
可能拋出的異常類型有:
class java.lang.NumberFormatException
執(zhí)行protectedMethod()方法
返回值為:12
名稱為:privateMethod
是否允許帶有可變數(shù)量的參數(shù):true
入口參數(shù)類型依次為:
class [Ljava.lang.String;
返回值類型為:class java.lang.String
可能拋出的異常類型有:
在執(zhí)行方法時(shí)拋出異常,下面執(zhí)行setAccessible()方法!
執(zhí)行privateMethod()方法
返回值為:
*/

二、使用Annotation功能

1、定義Annotation類型

在定義Annotation類型時(shí),也需要用到用來(lái)定義接口的interface關(guān)鍵字,不過需要在interface關(guān)鍵字前加一個(gè)“@”符號(hào),即定義Annotation類型的關(guān)鍵字為@interface,這個(gè)關(guān)鍵字的隱含意思是繼承了java.lang.annotation.Annotation接口。

public @interface NoMemberAnnotation{

String value();

}

@interface:聲明關(guān)鍵字。

NoMemberAnnotation:注解名稱。

String:成員類型。

value:成員名稱。

定義并使用Annotation類型

①定義Annotation類型@Constructor_Annotation的有效范圍為運(yùn)行時(shí)加載Annotation到JVM中。

package annotationbao;
 import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
 @Target(ElementType.CONSTRUCTOR)        // 用于構(gòu)造方法
@Retention(RetentionPolicy.RUNTIME)    // 在運(yùn)行時(shí)加載Annotation到JVM中
public @interface Constructor_Annotation{
    String value() default "默認(rèn)構(gòu)造方法";         // 定義一個(gè)具有默認(rèn)值的String型成員
}

②定義一個(gè)來(lái)注釋字段、方法和參數(shù)的Annotation類型@Field_Method_Parameter_Annotation的有效范圍為運(yùn)行時(shí)加載Annotation到JVM中

package annotationbao;
 import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
 @Target({ElementType.FIELD,ElementType.METHOD,ElementType.PARAMETER})   // 用于字段、方法和參數(shù)
@Retention(RetentionPolicy.RUNTIME)     // 在運(yùn)行時(shí)加載Annotation到JVM中
public @interface Field_Method_Parameter_Annotation{
	String descrblic();     // 定義一個(gè)沒有默認(rèn)值的String型成員
	Class type() default void.class;    // 定義一個(gè)具有默認(rèn)值的Class型成員
}

③編寫一個(gè)Record類,在該類中運(yùn)用前面定義Annotation類型的@Constructor_Annotation和@Field_Method_Parameter_Annotation對(duì)構(gòu)造方法、字段、方法和參數(shù)進(jìn)行注釋。

package annotationbao;
 public class Record {
 	@Field_Method_Parameter_Annotation(describe = "編號(hào)", type = int.class)
	int id;
 	@Field_Method_Parameter_Annotation(describe = "姓名", type = String.class)
	String name;
 	@Constructor_Annotation()
	public Record() {
	}
 	@Constructor_Annotation("立即初始化構(gòu)造方法")
	public Record(
			@Field_Method_Parameter_Annotation(describe = "編號(hào)", type = int.class)
			int id,
			@Field_Method_Parameter_Annotation(describe = "姓名", type = String.class)
			String name) {
		this.id = id;
		this.name = name;
	}
 	@Field_Method_Parameter_Annotation(describe = "獲得編號(hào)", type = int.class)
	public int getId() {
		return id;
	}
 	@Field_Method_Parameter_Annotation(describe = "設(shè)置編號(hào)")
	public void setId(
			@Field_Method_Parameter_Annotation(describe = "編號(hào)", type = int.class)int id) {
		this.id = id;
	}
 	@Field_Method_Parameter_Annotation(describe = "獲得姓名", type = String.class)
	public String getName() {
		return name;
	}
 	@Field_Method_Parameter_Annotation(describe = "設(shè)置姓名")
	public void setName(
			@Field_Method_Parameter_Annotation(describe = "姓名", type = String.class)String name) {
		this.name = name;
	}
 }

2、訪問Annotation信息

如果在定義Annotation類型時(shí)將@Retention設(shè)置為RetentionPolicy.RUNTIME,那么在運(yùn)行程序時(shí)通過反射就可以獲取到相關(guān)的Annotation信息,如獲取構(gòu)造方法、字段和方法的Annotation信息。

聯(lián)合以上的定義并使用Annotation類型,通過反射訪問Record類中的Annotation信息。

package annotationbao;
import java.lang.annotation.*;
import java.lang.reflect.*;
 public class Main_05 {
 	public static void main(String[] args) {
 		Class recordC = null;
		try {
			recordC = Class.forName("Record");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
 		System.out.println("------ 構(gòu)造方法的描述如下 ------");
		Constructor[] declaredConstructors = recordC
				.getDeclaredConstructors(); // 獲得所有構(gòu)造方法
		for (int i = 0; i < declaredConstructors.length; i++) {
			Constructor constructor = declaredConstructors[i]; // 遍歷構(gòu)造方法
			// 查看是否具有指定類型的注釋
			if (constructor
					.isAnnotationPresent(Constructor_Annotation.class)) {
				// 獲得指定類型的注釋
				Constructor_Annotation ca = (Constructor_Annotation) constructor
						.getAnnotation(Constructor_Annotation.class);
				System.out.println(ca.value()); // 獲得注釋信息
			}
			Annotation[][] parameterAnnotations = constructor
					.getParameterAnnotations(); // 獲得參數(shù)的注釋
			for (int j = 0; j < parameterAnnotations.length; j++) {
				// 獲得指定參數(shù)注釋的長(zhǎng)度
				int length = parameterAnnotations[j].length;
				if (length == 0) // 如果長(zhǎng)度為0則表示沒有為該參數(shù)添加注釋
					System.out.println("    未添加Annotation的參數(shù)");
				else
					for (int k = 0; k < length; k++) {
						// 獲得參數(shù)的注釋
						Field_Method_Parameter_Annotation pa = (Field_Method_Parameter_Annotation) parameterAnnotations[j][k];
						System.out.print("    " + pa.describe()); // 獲得參數(shù)描述
						System.out.println("    " + pa.type()); // 獲得參數(shù)類型
					}
			}
			System.out.println();
		}
 		System.out.println();
 		System.out.println("-------- 字段的描述如下 --------");
		Field[] declaredFields = recordC.getDeclaredFields(); // 獲得所有字段
		for (int i = 0; i < declaredFields.length; i++) {
			Field field = declaredFields[i]; // 遍歷字段
			// 查看是否具有指定類型的注釋
			if (field
					.isAnnotationPresent(Field_Method_Parameter_Annotation.class)) {
				// 獲得指定類型的注釋
				Field_Method_Parameter_Annotation fa = field
						.getAnnotation(Field_Method_Parameter_Annotation.class);
				System.out.print("    " + fa.describe()); // 獲得字段的描述
				System.out.println("    " + fa.type()); // 獲得字段的類型
			}
		}
 		System.out.println();
 		System.out.println("-------- 方法的描述如下 --------");
		Method[] methods = recordC.getDeclaredMethods(); // 獲得所有方法
		for (int i = 0; i < methods.length; i++) {
			Method method = methods[i]; // 遍歷方法
			// 查看是否具有指定類型的注釋
			if (method
					.isAnnotationPresent(Field_Method_Parameter_Annotation.class)) {
				// 獲得指定類型的注釋
				Field_Method_Parameter_Annotation ma = method
						.getAnnotation(Field_Method_Parameter_Annotation.class);
				System.out.println(ma.describe()); // 獲得方法的描述
				System.out.println(ma.type()); // 獲得方法的返回值類型
			}
			Annotation[][] parameterAnnotations = method
					.getParameterAnnotations(); // 獲得參數(shù)的注釋
			for (int j = 0; j < parameterAnnotations.length; j++) {
				int length = parameterAnnotations[j].length; // 獲得指定參數(shù)注釋的長(zhǎng)度
				if (length == 0) // 如果長(zhǎng)度為0表示沒有為該參數(shù)添加注釋
					System.out.println("    未添加Annotation的參數(shù)");
				else
					for (int k = 0; k < length; k++) {
						// 獲得指定類型的注釋
						Field_Method_Parameter_Annotation pa = (Field_Method_Parameter_Annotation) parameterAnnotations[j][k];
						System.out.print("    " + pa.describe()); // 獲得參數(shù)的描述
						System.out.println("    " + pa.type()); // 獲得參數(shù)的類型
					}
			}
			System.out.println();
		}
 	}
}
 

/*輸出結(jié)果:
------ 構(gòu)造方法的描述如下 ------
默認(rèn)構(gòu)造方法
立即初始化構(gòu)造方法
編號(hào) int
姓名 class java.lang.String
-------- 字段的描述如下 --------
編號(hào) int
姓名 class java.lang.String
-------- 方法的描述如下 --------
獲得姓名
class java.lang.String
設(shè)置姓名
void
姓名 class java.lang.String
獲得編號(hào)
int
設(shè)置編號(hào)
void
編號(hào) int

*/

總結(jié)

本篇文章就到這里了,希望能夠給你帶來(lái)幫助,也希望您能夠多多關(guān)注腳本之家的更多內(nèi)容!

相關(guān)文章

  • 基于Java數(shù)組實(shí)現(xiàn)循環(huán)隊(duì)列的兩種方法小結(jié)

    基于Java數(shù)組實(shí)現(xiàn)循環(huán)隊(duì)列的兩種方法小結(jié)

    下面小編就為大家分享一篇基于Java數(shù)組實(shí)現(xiàn)循環(huán)隊(duì)列的兩種方法小結(jié),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧
    2017-12-12
  • 分布式難題ElasticSearch解決大數(shù)據(jù)量檢索面試

    分布式難題ElasticSearch解決大數(shù)據(jù)量檢索面試

    這篇文章主要為大家介紹了分布式面試難題,ElasticSearch解決大數(shù)據(jù)量檢索的問題分析回答,讓面試官無(wú)話可說(shuō),幫助大家實(shí)現(xiàn)面試開薪自由
    2022-03-03
  • Java源碼解析之object類

    Java源碼解析之object類

    前些天看到別人討論閱讀源碼有什么用這個(gè)問題,有一句話說(shuō)的特別好:學(xué)習(xí)別人實(shí)現(xiàn)某個(gè)功能的設(shè)計(jì)思路,來(lái)提高自己的編程水平。本文主要介紹了Java源碼解析之object類,需要的朋友可以參考。
    2017-10-10
  • 一篇文章看懂Java異常處理

    一篇文章看懂Java異常處理

    異常是程序中的一些錯(cuò)誤,但并不是所有的錯(cuò)誤都是異常,并且錯(cuò)誤有時(shí)候是可以避免的,這篇文章主要給大家介紹了關(guān)于Java異常處理的相關(guān)資料,需要的朋友可以參考下
    2021-11-11
  • 新的Java訪問mysql數(shù)據(jù)庫(kù)工具類的操作代碼

    新的Java訪問mysql數(shù)據(jù)庫(kù)工具類的操作代碼

    本文通過實(shí)例代碼給大家介紹新的Java訪問mysql數(shù)據(jù)庫(kù)工具類的方法,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2021-12-12
  • Spring注解驅(qū)動(dòng)之關(guān)于@Bean注解指定初始化和銷毀的方法

    Spring注解驅(qū)動(dòng)之關(guān)于@Bean注解指定初始化和銷毀的方法

    這篇文章主要介紹了Spring注解驅(qū)動(dòng)之關(guān)于@Bean注解指定初始化和銷毀的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • 深入理解Java設(shè)計(jì)模式之狀態(tài)模式

    深入理解Java設(shè)計(jì)模式之狀態(tài)模式

    這篇文章主要介紹了JAVA設(shè)計(jì)模式之職責(zé)鏈模式的的相關(guān)資料,文中示例代碼非常詳細(xì),供大家參考和學(xué)習(xí),感興趣的朋友可以了解
    2021-11-11
  • SpringBoot中MybatisX插件的簡(jiǎn)單使用教程(圖文)

    SpringBoot中MybatisX插件的簡(jiǎn)單使用教程(圖文)

    MybatisX 是一款基于 IDEA 的快速開發(fā)插件,方便在使用mybatis以及mybatis-plus開始時(shí)簡(jiǎn)化繁瑣的重復(fù)操作,本文主要介紹了SpringBoot中MybatisX插件的簡(jiǎn)單使用教程,感興趣的可以了解一下
    2023-06-06
  • SpringBoot?常用讀取配置文件的三種方法詳解

    SpringBoot?常用讀取配置文件的三種方法詳解

    這篇文章主要介紹了SpringBoot?常用讀取配置文件的3種方法,通過本文學(xué)習(xí)可以解決Spring Boot有哪些常用的讀取配置文件方式,一些復(fù)雜的數(shù)據(jù)結(jié)構(gòu),如list,map如何配置,帶著這些問題一起通過本文學(xué)習(xí)吧
    2022-09-09
  • SpringBoot3整合SpringCloud啟動(dòng)后nacos報(bào)錯(cuò)獲取不到配置、無(wú)法注冊(cè)服務(wù)的解決方案

    SpringBoot3整合SpringCloud啟動(dòng)后nacos報(bào)錯(cuò)獲取不到配置、無(wú)法注冊(cè)服務(wù)的解決方案

    文章介紹了如何使用Spring Boot 3.3.4和Spring Cloud 2023.0.3搭建微服務(wù)項(xiàng)目,并解決與Nacos服務(wù)注冊(cè)發(fā)現(xiàn)和配置中心的集成問題,主要解決了依賴版本不兼容、配置文件導(dǎo)入問題及服務(wù)注冊(cè)失敗等問題,感興趣的朋友跟隨小編一起看看吧
    2025-02-02

最新評(píng)論

明水县| 湄潭县| 梁河县| 南乐县| 元谋县| 旺苍县| 年辖:市辖区| 平利县| 澎湖县| 政和县| 得荣县| 河池市| 滦平县| 通渭县| 来宾市| 宜章县| 福鼎市| 大埔区| 灵山县| 张家港市| 保康县| 安庆市| 凤庆县| 蚌埠市| 尚志市| 百色市| 梁山县| 博客| 石河子市| 夹江县| 潮安县| 永嘉县| 加查县| 沅陵县| 临泉县| 五寨县| 永丰县| 名山县| 华亭县| 黔南| 邢台市|