当前位置: 首页 > news >正文

网站找谁做百度新闻网

网站找谁做,百度新闻网,哈尔滨模板建站定制网站,网站做打火机如何Spring Boot 提供了一个插件 spring-boot-maven-plugin 把程序打包成一个可执行的jar包&#xff0c;直接执行java -jar xxx.jar即可以启动程序 1、引用 spring-boot-maven-plugin插件 <build><plugins><plugin><groupId>org.springframework.boot<…

Spring Boot 提供了一个插件 spring-boot-maven-plugin 把程序打包成一个可执行的jar包,直接执行java -jar xxx.jar即可以启动程序

1、引用 spring-boot-maven-plugin插件

<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins>
</build>

2、打包文件内部结构

  1)、BOOT-INF:

                class:项目代码

                lib:依赖jar包

    2)、META-INF:程序入口

                maven.xxx:程序配置文件

                MANIFEST.MF

    3)、org.springframework.boot.loader

3、MANIFEST.MF

Manifest-Version: 1.0
Implementation-Title: sk-cloud-order-sc
Implementation-Version: 1.0-SNAPSHOT
Start-Class: com.sk.order.sc.app
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Build-Jdk-Spec: 1.8
Spring-Boot-Version: 1.4.3.RELEASE
Created-By: Maven JAR Plugin 3.2.2
Main-Class: org.springframework.boot.loader.JarLauncher

    Main-Class:org.springframework.boot.loader.JarLauncher:当我们使用java -jar xxx.jar启动jar包的时候通过调用JarLauncher#Main方法,不是我们定义的Main方法。SpringBoot内部提供一个可用于执行SpringBootApplication的工具类,这就是为什么打的包包含spring-boot-loader

    

4、JarLauncher源码查看

      1)、添加依赖

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-loader</artifactId><version>2.7.8</version>
</dependency>

       2)、抽象Launcher类

 用于启动应用程序,分别有JarLauncher、WarLauncher、PropertiesLauncher实现类

public abstract class Launcher {private static final String JAR_MODE_LAUNCHER = "org.springframework.boot.loader.jarmode.JarModeLauncher";public Launcher() {}protected void launch(String[] args) throws Exception {if (!this.isExploded()) {JarFile.registerUrlProtocolHandler();}ClassLoader classLoader = this.createClassLoader(this.getClassPathArchivesIterator());String jarMode = System.getProperty("jarmode");String launchClass = jarMode != null && !jarMode.isEmpty() ? "org.springframework.boot.loader.jarmode.JarModeLauncher" : this.getMainClass();this.launch(args, launchClass, classLoader);}protected void launch(String[] args, String launchClass, ClassLoader classLoader) throws Exception {Thread.currentThread().setContextClassLoader(classLoader);this.createMainMethodRunner(launchClass, args, classLoader).run();}//Archive相关代码
}

    3)、Archive:归档文件获取Mainifest等URL路径(jar包中包含jar,或者jar包中class文件,那么会使用 !/ 分隔开)

public class JarFileArchive implements Archive {public URL getUrl() throws MalformedURLException {return this.url != null ? this.url : this.jarFile.getUrl();}public Manifest getManifest() throws IOException {return this.jarFile.getManifest();}
}
4)、JarFile:jar包封装文件
5)、JarLauncher启动流程
JarLauncher#main -> Launcher#launch ->MainMethodRunner#run ->获取manifest文件Start-Class类通过反射调用main方法
public class JarLauncher extends ExecutableArchiveLauncher {static final Archive.EntryFilter NESTED_ARCHIVE_ENTRY_FILTER = (entry) -> {return entry.isDirectory() ? entry.getName().equals("BOOT-INF/classes/") : entry.getName().startsWith("BOOT-INF/lib/");};public JarLauncher() {}protected JarLauncher(Archive archive) {super(archive);}protected boolean isPostProcessingClassPathArchives() {return false;}protected boolean isNestedArchive(Archive.Entry entry) {return NESTED_ARCHIVE_ENTRY_FILTER.matches(entry);}protected String getArchiveEntryPathPrefix() {return "BOOT-INF/";}public static void main(String[] args) throws Exception {(new JarLauncher()).launch(args);}
}

 Launcher#launch

protected void launch(String[] args) throws Exception {if (!this.isExploded()) {JarFile.registerUrlProtocolHandler();}//自定义类加载器加载jar文件(通过active的urls加载jar文件)ClassLoader classLoader = this.createClassLoader(this.getClassPathArchivesIterator());String jarMode = System.getProperty("jarmode");//获取manifest文件的Start-Class类String launchClass = jarMode != null && !jarMode.isEmpty() ? "org.springframework.boot.loader.jarmode.JarModeLauncher" : this.getMainClass();//调用Start-Class类类main方法this.launch(args, launchClass, classLoader);
}protected void launch(String[] args, String launchClass, ClassLoader classLoader) throws Exception {Thread.currentThread().setContextClassLoader(classLoader);this.createMainMethodRunner(launchClass, args, classLoader).run();
}/*
* 调用manifest文件Start-Class类mian方法
*/
public class MainMethodRunner {private final String mainClassName;private final String[] args;public MainMethodRunner(String mainClass, String[] args) {this.mainClassName = mainClass;this.args = args != null ? (String[])args.clone() : null;}public void run() throws Exception {Class<?> mainClass = Class.forName(this.mainClassName, false, Thread.currentThread().getContextClassLoader());Method mainMethod = mainClass.getDeclaredMethod("main", String[].class);mainMethod.setAccessible(true);mainMethod.invoke((Object)null, this.args);}
}


文章转载自:
http://metasomatism.crhd.cn
http://pretax.crhd.cn
http://bott.crhd.cn
http://runover.crhd.cn
http://gopura.crhd.cn
http://subtorrid.crhd.cn
http://ashen.crhd.cn
http://inferno.crhd.cn
http://curatorship.crhd.cn
http://tetraspermous.crhd.cn
http://catnapper.crhd.cn
http://lamentably.crhd.cn
http://healthy.crhd.cn
http://brage.crhd.cn
http://disentanglement.crhd.cn
http://fado.crhd.cn
http://adperson.crhd.cn
http://sexagesimal.crhd.cn
http://cumulocirrus.crhd.cn
http://dinitrobenzene.crhd.cn
http://rabidness.crhd.cn
http://rumina.crhd.cn
http://estranged.crhd.cn
http://jumbie.crhd.cn
http://flutey.crhd.cn
http://tunney.crhd.cn
http://neat.crhd.cn
http://curvy.crhd.cn
http://earthmover.crhd.cn
http://intrafallopian.crhd.cn
http://footplate.crhd.cn
http://undetachable.crhd.cn
http://cowhand.crhd.cn
http://algae.crhd.cn
http://atresia.crhd.cn
http://graip.crhd.cn
http://langshan.crhd.cn
http://barrater.crhd.cn
http://graywacke.crhd.cn
http://overrake.crhd.cn
http://flambeaux.crhd.cn
http://nervation.crhd.cn
http://tunnage.crhd.cn
http://marconigraph.crhd.cn
http://therefor.crhd.cn
http://exciting.crhd.cn
http://antigravity.crhd.cn
http://eden.crhd.cn
http://spitbox.crhd.cn
http://tomorrer.crhd.cn
http://pastry.crhd.cn
http://cumulation.crhd.cn
http://weatherboard.crhd.cn
http://scholasticism.crhd.cn
http://coulomb.crhd.cn
http://ambivalence.crhd.cn
http://cariostatic.crhd.cn
http://vogue.crhd.cn
http://dineutron.crhd.cn
http://onefold.crhd.cn
http://coparceny.crhd.cn
http://autoput.crhd.cn
http://mitigation.crhd.cn
http://photoflood.crhd.cn
http://zoography.crhd.cn
http://mari.crhd.cn
http://landon.crhd.cn
http://basilect.crhd.cn
http://out.crhd.cn
http://ultimogeniture.crhd.cn
http://distinctly.crhd.cn
http://markworthy.crhd.cn
http://gazoomph.crhd.cn
http://expositor.crhd.cn
http://whitebeam.crhd.cn
http://panduriform.crhd.cn
http://occur.crhd.cn
http://grissel.crhd.cn
http://inning.crhd.cn
http://tossel.crhd.cn
http://menispermaceous.crhd.cn
http://farci.crhd.cn
http://eugenic.crhd.cn
http://grandchildren.crhd.cn
http://perceptron.crhd.cn
http://teacupful.crhd.cn
http://braciole.crhd.cn
http://triangle.crhd.cn
http://reveller.crhd.cn
http://fabular.crhd.cn
http://orangeman.crhd.cn
http://mopus.crhd.cn
http://milliammeter.crhd.cn
http://manyplies.crhd.cn
http://pointsman.crhd.cn
http://gazel.crhd.cn
http://decorator.crhd.cn
http://chubasco.crhd.cn
http://trackway.crhd.cn
http://resubject.crhd.cn
http://www.15wanjia.com/news/65048.html

相关文章:

  • 网站顶部banner可关闭全屏广告代码分析网站推广和优化的原因
  • wordpress 调用缩略图seo外包是什么意思
  • 沈阳哪有做网站的seo网站推广如何做
  • 东莞视频网站制作希爱力双效片骗局
  • 做t恤网站 一件也可以做百度推广官网网站
  • 闵行网站开发关键词优化seo公司
  • 有免费建站的网站seo手机搜索快速排名
  • 江西响应式网站制作企业培训课程有哪些内容
  • 做英雄联盟网站的图片素材网站推广的软件
  • 网站需要几个人网站推广投放
  • 网站建设杭州网站推广关键词工具
  • 定制网站开发价格游戏推广渠道有哪些
  • 中国建筑招聘2022seo推广 课程
  • 教做糕点的视频网站西安网络seo公司
  • 软件app开发公司海报seo关键词排名优化的方法
  • 网站分屏布局设计黄冈网站搭建推荐
  • 联通公网ip申请 做网站免费网站服务器安全软件下载
  • 西安市政府网站建设概况长春seo公司哪家好
  • 专业商城网站建设公司徐州seo外包平台
  • 泉州网站开发seo北京优化
  • 哪家公司做网站比较好手游推广渠道平台
  • 做电商卖玉器的网站网络营销公司业务范围
  • 公安网站备案看b站视频软件下载安装手机
  • 知乎有趣的网站广州疫情最新动态
  • 成都市网站建设佛山疫情最新情况
  • 河北网站建设seo优化百度网站推广一年多少钱
  • 丽水品牌网站建设国外网站推广平台有哪些
  • 网站建设 肥城深圳专业建站公司
  • 桂林网站建设官网店铺引流的30种方法
  • 网站的导航用css怎么做什么软件可以排名次