类 MainClassFinder
java.lang.Object
org.springframework.boot.loader.tools.MainClassFinder
Finds any class with a
public static main
method by performing a breadth first
search.- 从以下版本开始:
- 1.0.0
- 作者:
- Phillip Webb, Andy Wilkinson
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static String
findMainClass
(File rootDirectory) Find the main class from a given directory.static String
findMainClass
(JarFile jarFile, String classesLocation) Find the main class in a given jar file.static String
findSingleMainClass
(File rootDirectory) Find a single main class from the givenrootDirectory
.static String
findSingleMainClass
(File rootDirectory, String annotationName) Find a single main class from the givenrootDirectory
.static String
findSingleMainClass
(JarFile jarFile, String classesLocation) Find a single main class in a given jar file.static String
findSingleMainClass
(JarFile jarFile, String classesLocation, String annotationName) Find a single main class in a given jar file.
-
构造器详细资料
-
MainClassFinder
public MainClassFinder()
-
-
方法详细资料
-
findMainClass
Find the main class from a given directory.- 参数:
rootDirectory
- the root directory to search- 返回:
- the main class or
null
- 抛出:
IOException
- if the directory cannot be read
-
findSingleMainClass
Find a single main class from the givenrootDirectory
.- 参数:
rootDirectory
- the root directory to search- 返回:
- the main class or
null
- 抛出:
IOException
- if the directory cannot be read
-
findSingleMainClass
public static String findSingleMainClass(File rootDirectory, String annotationName) throws IOException Find a single main class from the givenrootDirectory
. A main class annotated with an annotation with the givenannotationName
will be preferred over a main class with no such annotation.- 参数:
rootDirectory
- the root directory to searchannotationName
- the name of the annotation that may be present on the main class- 返回:
- the main class or
null
- 抛出:
IOException
- if the directory cannot be read
-
findMainClass
Find the main class in a given jar file.- 参数:
jarFile
- the jar file to searchclassesLocation
- the location within the jar containing classes- 返回:
- the main class or
null
- 抛出:
IOException
- if the jar file cannot be read
-
findSingleMainClass
public static String findSingleMainClass(JarFile jarFile, String classesLocation) throws IOException Find a single main class in a given jar file.- 参数:
jarFile
- the jar file to searchclassesLocation
- the location within the jar containing classes- 返回:
- the main class or
null
- 抛出:
IOException
- if the jar file cannot be read
-
findSingleMainClass
public static String findSingleMainClass(JarFile jarFile, String classesLocation, String annotationName) throws IOException Find a single main class in a given jar file. A main class annotated with an annotation with the givenannotationName
will be preferred over a main class with no such annotation.- 参数:
jarFile
- the jar file to searchclassesLocation
- the location within the jar containing classesannotationName
- the name of the annotation that may be present on the main class- 返回:
- the main class or
null
- 抛出:
IOException
- if the jar file cannot be read
-