From 31b8a17e65526a7c39804c7c749603fe63816ab5 Mon Sep 17 00:00:00 2001 From: dingzhaojun Date: Thu, 22 Feb 2024 12:10:38 +0800 Subject: [PATCH] classpath --- dependency-reduced-pom.xml | 36 ++++++++++++ java-run-order-audi.bat | 1 + java-run-order-merceds.bat | 1 + java-run.bat | 1 + pom.xml | 62 ++++++++++---------- src/main/java/net/risesoft/demo/Example.java | 25 +++----- 6 files changed, 77 insertions(+), 49 deletions(-) create mode 100644 dependency-reduced-pom.xml create mode 100644 java-run-order-audi.bat create mode 100644 java-run-order-merceds.bat create mode 100644 java-run.bat diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml new file mode 100644 index 0000000..f6db7d6 --- /dev/null +++ b/dependency-reduced-pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + net.risesoft.demo + demo-car + 1.0 + + + + maven-shade-plugin + 3.5.2 + + + package + + shade + + + + + net.risesoft.demo.Example + + + META-INF/spring.handlers + + + META-INF/spring.schemas + + + + + + + + + diff --git a/java-run-order-audi.bat b/java-run-order-audi.bat new file mode 100644 index 0000000..b0f6d90 --- /dev/null +++ b/java-run-order-audi.bat @@ -0,0 +1 @@ +java -cp "./target/*;./target/lib/demo-audi-1.0.jar;;./target/lib/demo-merceds-1.0.jar" net.risesoft.demo.Example \ No newline at end of file diff --git a/java-run-order-merceds.bat b/java-run-order-merceds.bat new file mode 100644 index 0000000..7db291e --- /dev/null +++ b/java-run-order-merceds.bat @@ -0,0 +1 @@ +java -cp "./target/*;./target/lib/demo-merceds-1.0.jar;./target/lib/demo-audi-1.0.jar;" net.risesoft.demo.Example \ No newline at end of file diff --git a/java-run.bat b/java-run.bat new file mode 100644 index 0000000..30de919 --- /dev/null +++ b/java-run.bat @@ -0,0 +1 @@ +java -cp "./target/*;./target/lib/*" net.risesoft.demo.Example \ No newline at end of file diff --git a/pom.xml b/pom.xml index ff59bbb..c84606c 100644 --- a/pom.xml +++ b/pom.xml @@ -29,9 +29,7 @@ net.risesoft.demo.Example true - - true - + flase lib/ @@ -58,10 +56,10 @@ - + - - org.apache.maven.plugins - maven-shade-plugin - 2.4.1 - - - package - - shade - - - - - net.risesoft.demo.Example - - - META-INF/spring.handlers - - - META-INF/spring.schemas - - - - - - + \ No newline at end of file diff --git a/src/main/java/net/risesoft/demo/Example.java b/src/main/java/net/risesoft/demo/Example.java index f959a59..b5690b9 100644 --- a/src/main/java/net/risesoft/demo/Example.java +++ b/src/main/java/net/risesoft/demo/Example.java @@ -1,28 +1,19 @@ package net.risesoft.demo; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - public class Example { public static void main(String[] args) { Car car = new Car(); - System.out.println("当前车辆版本: " + car.getVersion()); + + System.out.println("当前车辆品牌: "); + System.out.println(car.getName()); + + System.out.println("当前车辆版本: "); + System.out.println(car.getVersion()); + System.out.println("当前 jar 包路径 : "); System.out.println(car.getClass().getProtectionDomain().getCodeSource().getLocation().getPath()); - Method[] declaredMethods = car.getClass().getDeclaredMethods(); - for (Method declaredMethod : declaredMethods) { - System.out.println("------------------"); - System.out.println("method name: " + declaredMethod.getName()); - List collect = Arrays.stream(declaredMethod.getParameterTypes()).map(Class::getName).collect(Collectors - .toList()); - if (!collect.isEmpty()) { - System.out.println("parameter type : " + collect); - } - System.out.println("------------------"); - } + } }