Java8 ã§ã¯åããã© Java11 ã§ã¯æ»ã¬ã³ã¼ãããã£ã¦ã調æ»ãããããåå ãããã ã£ãããåç¾ã«æéåã£ãã®ã§çµæãã¡ã¢ã£ã¦ããã
çºçæ¡ä»¶ã¯ä»¥ä¸ã®ã¨ããã§ããã
- fat jar ã
java -jar
ã§èµ·åããã¨çºçããã- gradle ããã®
bootRun
ãtest
ã§ã¯çºçããªãã(fat jar ããèµ·åãããããªãã¹ããæ¸ããªãéã)
- gradle ããã®
ForkJoinPool.commonPool()
ã§æä¾ãããã¹ã¬ããã§Thread.currentThread().getContextClassLoader()
) ãããªã½ã¼ã¹ããã¼ãããã- ããã¨
src/main/resources
é ä¸ã®ãªã½ã¼ã¹ãåç §ã§ããªã㦠null ã«ãªãã
- ããã¨
å®éã«æ»ãã ã³ã¼ãã¯ã¹ããªã¼ã ã® parallel()
) å
ã§ãªã½ã¼ã¹ãåç
§ãã¦ããã
åç¾ããã³ã¼ã (ããªãé) ã¯ä»¥ä¸ã®ã¨ããã§ãããããã Spring Initializr ã§çæããããã¸ã§ã¯ãã«ã¶ã£ãã㧠bootJar
ãã¤ããã
Java11 ã ã¨ã¢ã¯ã»ã¹ãããæã« getResourceAsStream
ã null ãè¿ãããããã®å¾ã® read
㧠NPE ãåãã¦ãã¾ãã
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause java.lang.NullPointerException: null at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:878) ~[guava-30.1-jre.jar!/:na] at com.google.common.io.ByteStreams.toByteArray(ByteStreams.java:220) ~[guava-30.1-jre.jar!/:na] at com.google.common.io.ByteSource.read(ByteSource.java:286) ~[guava-30.1-jre.jar!/:na] at com.google.common.io.ByteSource$AsCharSource.read(ByteSource.java:472) ~[guava-30.1-jre.jar!/:na] at com.example.demo.DemoController.lambda$index$1(DemoController.java:29) ~[classes!/:na] at java.base/java.util.stream.ReduceOps$2ReducingSink.accept(ReduceOps.java:123) ~[na:na] at java.base/java.util.stream.ReduceOps$2ReducingSink.combine(ReduceOps.java:135) ~[na:na] at java.base/java.util.stream.ReduceOps$2ReducingSink.combine(ReduceOps.java:107) ~[na:na] at java.base/java.util.stream.ReduceOps$ReduceTask.onCompletion(ReduceOps.java:959) ~[na:na] at java.base/java.util.concurrent.CountedCompleter.tryComplete(CountedCompleter.java:592) ~[na:na] at java.base/java.util.stream.AbstractTask.compute(AbstractTask.java:328) ~[na:na] at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746) ~[na:na] at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) ~[na:na] at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) ~[na:na] at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) ~[na:na] at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) ~[na:na] at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177) ~[na:na]
åé¿ããããã«ã¯ ClassPathResource ã使ãã¨è¯ãããã§ããã(æå ã®ã³ã¼ãã¯ããã§åé¿ãããã¨ãã§ããã)