OpenJDK 11.0.1をインストールしました。mvninstallを使用してアプリケーションを実行しようとすると、次のエラーが発生します。pox.xml.bindをpom.xmlに追加することで、必要な依存関係を修正として追加しましたが、そうではありません。うまくいくようですが、誰かがこの問題に直面しましたか?他に何かする必要がありますか?私のmvn --versionはこれを返します
Maven home: /usr/local/Cellar/maven/3.5.2/libexec
Java version: 11.0.1, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.2", Arch: "x86_64", family: "mac"
これを追加しましたが、問題は解決しませんでした
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
そして、これは私が得るものです
[INFO] --- maven-failsafe-plugin:2.20:integration-test (failsafe-integration-tests) @ name-sample-test ---
[WARNING] Error injecting: org.Apache.maven.plugin.failsafe.IntegrationTestMojo
Java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at Java.base/Java.lang.Class.getDeclaredConstructors0(Native Method)
at Java.base/Java.lang.Class.privateGetDeclaredConstructors(Class.Java:3138)
at Java.base/Java.lang.Class.getDeclaredConstructors(Class.Java:2358)
at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.Java:245)
at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.Java:99)
at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.Java:658)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.Java:882)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.Java:805)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.Java:282)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.Java:214)
at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.Java:1006)
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.Java:1038)
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.Java:1001)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.Java:1051)
at org.Eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.Java:48)
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.Java:81)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.Java:53)
at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.Java:65)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.Java:115)
at org.Eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.Java:176)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.Java:126)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.Java:68)
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.Java:63)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.Java:45)
at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.Java:1016)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.Java:1092)
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.Java:1012)
at org.Eclipse.sisu.inject.Guice4$1.get(Guice4.Java:162)
at org.Eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.Java:81)
at org.Eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.Java:51)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.Java:263)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.Java:255)
at org.Apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.Java:517)
at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:121)
at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:207)
at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:153)
at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:145)
at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:116)
at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:80)
at org.Apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.Java:51)
at org.Apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.Java:128)
at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:307)
at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:193)
at org.Apache.maven.DefaultMaven.execute(DefaultMaven.Java:106)
at org.Apache.maven.cli.MavenCli.execute(MavenCli.Java:863)
at org.Apache.maven.cli.MavenCli.doMain(MavenCli.Java:288)
at org.Apache.maven.cli.MavenCli.main(MavenCli.Java:199)
at Java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.base/Java.lang.reflect.Method.invoke(Method.Java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.Java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.Java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.Java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.Java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.Java:47)
Caused by: Java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.Java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.Java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.Java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.Java:239)
... 56 more
この依存関係も追加する必要があります。
<dependency>
<groupId>com.Sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
Spring Bootアプリを独自のJAXB実装を実行するスタンドアロンサーブレットコンテナーにデプロイしようとしたときに、以前に同様の問題がありました。アプリケーションは、Maven依存関係からのjaxb-api
を使用する代わりに、環境からJAXBライブラリーを使用することを強制されました。 Application.Java
に1行を含めることで修正できます。
public static void main(String[] args) {
// com.Sun.xml.bind.v2.ContextFactory comes from within your depedency
System.setProperty("javax.xml.bind.JAXBContextFactory", "com.Sun.xml.bind.v2.ContextFactory");
SpringApplication.run(MonolithicApplication.class, args);
}