Spring Boot Thin Jar with Gradle无法正常工作

问题描述

我试图切换到Spring Boot瘦jar,以便该依赖项不包含在jar中。我正在使用$ CI=false npm run build > [email protected] build /home/gitlab-runner-2/builds/WHJ93iRm/0/team-weanalyz/service-desk > react-scripts build Creating an optimized production build... [12129:0x3441490] 163356 ms: Mark-sweep 994.2 (1005.1) -> 992.1 (1005.4) MB,4996.1 / 0.1 ms (average mu = 0.068,current mu = 0.013) allocation failure scavenge might not succeed [12129:0x3441490] 168187 ms: Mark-sweep 994.7 (1005.4) -> 993.0 (1006.6) MB,4794.5 / 0.0 ms (average mu = 0.038,current mu = 0.008) allocation failure scavenge might not succeed ==== JS stack trace ========================================= 0: ExitFrame [pc: 0x13cf099] 1: StubFrame [pc: 0x13d0133] Security context: 0x21679f2408d1 2: SourceMapGenerator_serializeMappings [0x2ad643a32db1] [/home/gitlab-runner-2/builds/WHJ93iRm/0/team-weanalyz/service-desk/node_modules/source-map/lib/source-map-generator.js:~303] [pc=0x2cf51f68298d](this=0x2e99646fad91 ) 3: SourceMapGenerator_toJSON [0x2ad643a32e31] [/home/gitla... Fatal error: Ineffective mark-compacts near heap limit Allocation Failed - JavaScript heap out of memory 1: 0xa093f0 node::Abort() [node] 2: 0xa097fc node::OnFatalError(char const*,char const*) [node] 3: 0xb8431e v8::Utils::ReportOOMFailure(v8::internal::Isolate*,char const*,bool) [node] 4: 0xb84699 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*,bool) [node] 5: 0xd31055 [node] 6: 0xd316e6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node] 7: 0xd3df65 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector,v8::GCCallbackFlags) [node] 8: 0xd3ee15 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace,v8::internal::GarbageCollectionReason,v8::GCCallbackFlags) [node] 9: 0xd418cc v8::internal::Heap::AllocaterawWithRetryOrFail(int,v8::internal::AllocationType,v8::internal::Allocationorigin,v8::internal::AllocationAlignment) [node] 10: 0xd0837b v8::internal::Factory::NewFillerObject(int,bool,v8::internal::Allocationorigin) [node] 11: 0x1049fbe v8::internal::Runtime_AllocateInYoungGeneration(int,unsigned long*,v8::internal::Isolate*) [node] 12: 0x13cf099 [node] npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build: `react-scripts build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /home/gitlab-runner-2/.npm/_logs/2020-10-20T10_24_20_084Z-debug.log ERROR: Job Failed: exit status 1 gradle插件

thin-launcher

但是,运行plugins { id 'org.springframework.boot.experimental.thin-launcher' version '1.0.25.RELEASE' } 任务时出现以下错误消息:

清单属性的值不能为null(Key = Start-Class)。

我尝试通过几种方式指定thinJar属性

Start-Class

使用gradle thinJar { manifest { attributes 'Start-Class': "at.mypackage.Application" } } bootJar { manifest { attributes 'Start-Class': "at.mypackage.Application" } } 插件并指定application属性也不起作用。没有Thin Jar插件,一切都会按预期进行。

感谢您的帮助!

解决方法

您似乎受到issue #149的影响-“收到有关缺少清单属性(开始类)值的错误”。撰写此答案时尚无解决方案。项目维护者正在寻求帮助。

提到的解决方法:

  1. 使用Gradle 5
  2. 使用Gradle 6.0.1-simple example正在使用