spring boot fatjar的扫描
spring-boot-maven-plugin fat jar的结构 fat jar问题 问题:Jersey doesn’t always work with Spring Boot fat jars
发布说明:1.4版本提供了处理方法https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.4-Release-Notes
处理方式 打包 打包插件添加需要特别处理的jar包如:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <requiresUnpack> <!--指定需要unpack的依赖--> <dependency> <groupId>com.netflix.eureka</groupId> <artifactId>eureka-core</artifactId> </dependency> <dependency> <groupId>com.netflix.eureka</groupId> <artifactId>eureka-client</artifactId> </dependency> </requiresUnpack> </configuration> </plugin> </plugins> </build> 查看插件打完的fat jar信息
spring boot 应用启动逻辑 springboot的JarLauncher继承自ExecutableArchiveLauncher,会从manifest文件中获取main-class,start-class
spring boot 实现了自定义的classLoader——LaunchedURLClassLoader,以当前fat jar开始进行扫描BOOT-INF/classes/,BOOT-INF/lib/
protected Archive getNestedArchive(Archive.Entry entry) throws IOException { JarEntry jarEntry = ((JarFileEntry)entry).getJarEntry(); // 对需要unpack的jar 特殊处理 if (jarEntry.getComment().startsWith("UNPACK:")) return getUnpackedNestedArchive(jarEntry); try { JarFile jarFile = this.
[Read More]