今日、私はメールの送信を検討していますが、
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.5</version>
</dependency>
pom.xmlにアクセスしてサーバーにデプロイすると、「Bean Validationプロバイダーが見つからないため、構成を作成できません。クラスパスにHibernate Validator(RI)などのプロバイダーを追加してください」というメッセージが表示されます。検証例外。
上記の依存関係とテンプレートMVCプロジェクトへの電子メールの依存関係を追加しました。
エラースタックトレース:
DEBUG: org.springframework.ui.context.support.UiApplicationContextUtils - Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.DelegatingThemeSource@20212230]
DEBUG: org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean - Failed to set up a Bean Validation provider
javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.Java:271)
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.Java:223)
at org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean.afterPropertiesSet(OptionalValidatorFactoryBean.Java:40)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.Java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.Java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.Java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.Java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.Java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.Java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.Java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.Java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.Java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:538)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.Java:667)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.Java:633)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.Java:681)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.Java:552)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.Java:493)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.Java:136)
at javax.servlet.GenericServlet.init(GenericServlet.Java:158)
at org.Apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.Java:1241)
at org.Apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.Java:1154)
at org.Apache.catalina.core.StandardWrapper.load(StandardWrapper.Java:1041)
at org.Apache.catalina.core.StandardContext.loadOnStartup(StandardContext.Java:4944)
at org.Apache.catalina.core.StandardContext.startInternal(StandardContext.Java:5230)
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:150)
at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1409)
at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1399)
at Java.util.concurrent.FutureTask.run(FutureTask.Java:266)
at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1142)
at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:617)
at Java.lang.Thread.run(Thread.Java:745)
Bean検証プロバイダーの依存関係(Hibernate Validatorなど)を追加します。 Bean Validation API依存関係はクラスパスで利用可能ですが、実装がありません。以下をpom.xmlに追加します
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.4.Final</version>
</dependency>
Hibernate Validatorなどの検証プロバイダーの依存関係を追加する必要があります。
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>5.2.1.Final</version>
</dependency>