2016-12-30 33 views
0

私はHow to disable Hibernate validation in a Spring Boot projectと同じ問題に遭遇し、同じことをしました。私が持っているapplication.ymlでは:spring-boot hibernateが有効化を無効にする

したがって、検証モードはnoneに設定する必要がありますが、そうではないように見えます。ログでは、私は見ることができます:

2016-12-30 23:39:44.166 INFO 63192 --- [on(2)-127.0.0.1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 
2016-12-30 23:39:44.215 DEBUG 63192 --- [on(2)-127.0.0.1] o.hibernate.jpa.internal.util.LogHelper : PersistenceUnitInfo [ 
     name: default 
     persistence provider classname: null 
     classloader: ParallelWebappClassLoader 
    context: ROOT 
    delegate: false 
----------> Parent Classloader: 
[email protected] 

     excludeUnlistedClasses: true 
     JTA datasource: null 
     Non JTA datasource: [email protected]{ConnectionPool[defaultAutoCommit=null; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=org.postgresql.Driver; maxAct 
ive=100; maxIdle=100; minIdle=10; initialSize=10; maxWait=30000; testOnBorrow=true; testOnReturn=false; timeBetweenEvictionRunsMillis=5000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=60000; testWhileIdle=false; testOnConnect= 
false; password=********; url=jdbc:postgresql://localhost:5432/MT-test; username=MoneyTracker; validationQuery=SELECT 1; validationQueryTimeout=-1; validatorClassName=null; validationInterval=3000; accessToUnderlyingConnectionAllowed=t 
rue; removeAbandoned=false; removeAbandonedTimeout=60; logAbandoned=false; connectionProperties=null; initSQL=null; jdbcInterceptors=null; jmxEnabled=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=0; useLock= 
false; dataSource=null; dataSourceJNDI=null; suspectTimeout=0; alternateUsernameAllowed=false; commitOnReturn=false; rollbackOnReturn=false; useDisposableConnectionFacade=true; logValidationErrors=false; propagateInterruptState=false; 
ignoreExceptionOnPreLoad=false; } 
     Transaction type: RESOURCE_LOCAL 
     PU root URL: file:/Users/romanrakus/Tomcats/apache-tomcat-8.5.4/webapps/ROOT/WEB-INF/lib/database-1.0-SNAPSHOT.jar 
     Shared Cache Mode: UNSPECIFIED 
     Validation Mode: AUTO 
     Jar files URLs [] 
     Managed classes names [ 
       cz.romanrakus.moneytracker.db.entities.Person 
       cz.romanrakus.moneytracker.db.entities.PersonRole 
       cz.romanrakus.moneytracker.db.entities.SpendingType 
       cz.romanrakus.moneytracker.db.entities.PredefinedCsvImport 
       cz.romanrakus.moneytracker.db.entities.Spending] 
     Mapping files names [] 
     Properties [] 

すべての設定は正しく読み込まれますが、検証モードは正しくありません。私は何か間違っているのですか?

検証モードプロパティをロードに関するログラインもあります:検証モードがまだAUTOに設定されているのはなぜ

2016-12-30 23:50:01.534 DEBUG 63192 --- [on(7)-127.0.0.1] org.springframework.jndi.JndiTemplate : Looking up JNDI object with name [java:comp/env/spring.jpa.properties.javax.persistence.validation.mode] 
2016-12-30 23:50:01.534 DEBUG 63192 --- [on(7)-127.0.0.1] o.s.jndi.JndiLocatorDelegate    : Converted JNDI name [java:comp/env/spring.jpa.properties.javax.persistence.validation.mode] not found - trying original name [spring.jpa.properties.javax.persistence.validation.mode]. javax.naming.NameNotFoundException: Name [spring.jpa.properties.javax.persistence.validation.mode] is not bound in this Context. Unable to find [spring.jpa.properties.javax.persistence.validation.mode]. 
2016-12-30 23:50:01.534 DEBUG 63192 --- [on(7)-127.0.0.1] org.springframework.jndi.JndiTemplate : Looking up JNDI object with name [spring.jpa.properties.javax.persistence.validation.mode] 
2016-12-30 23:50:01.534 DEBUG 63192 --- [on(7)-127.0.0.1] o.s.jndi.JndiPropertySource    : JNDI lookup for name [spring.jpa.properties.javax.persistence.validation.mode] threw NamingException with message: Name [spring.jpa.properties.javax.persistence.validation.mode] is not bound in this Context. Unable to find [spring.jpa.properties.javax.persistence.validation.mode].. Returning null. 
2016-12-30 23:50:01.534 DEBUG 63192 --- [on(7)-127.0.0.1] o.s.c.e.PropertySourcesPropertyResolver : Found key 'spring.jpa.properties.javax.persistence.validation.mode' in [applicationConfigurationProperties] with type [String] 

は?春から注入された豆を使ってバリデータークラスを作るために何ができるのですか?

UPDATE

私は検証モードが正しく(ログに何か他のものであっても)解析され、設定されていることが判明デバッグ中。しかし、依然として、アプリケーションはSpring Validatorの代わりにHibernate Validatorを使用しています。私はというプロパティに、validatorという名前のBeanへの参照を含めることも考えました。しかし、まだ運:(私はそれが重要な場合、私は知らないWebSecurityConfigurerAdapterを使用してい

+0

あなたのyamは有効ではないと思われます。プロパティのキーは "javax.validation.persistent.mode"ですが、そこに4つの入れ子オブジェクト –

+0

@StephaneNic​​ollあなたのコメントをありがとうございます。正しいプロパティ名は 'javax.persistence.validation.mode'です。ネストを変更しようとするとオブジェクトをドット表記で1つのオブジェクトに変換すると、変更はありません。それでも 'AUTO'検証モードです。無効な値( 'invalid'など)を設定しようとしましたが、例外(' org.hibernate.HibernateException:javax.persistence.validation.modeの不明な検証モード:無効 ')から開始されません。ネストされた表記法とドット表記法は同じように機能します。 –

+0

私は非常に異なる問題があることが判明しました。バリデータ(バネ制約バリデーター)をJSFに追加する必要がありました。私のために働く解決策はhttp://stackoverflow.com/a/21279420/5788897です。 –

答えて

0

それは私が非常に異なる問題を抱えていたことが判明し何の。私はにバリ(春の制約バリデータ)を追加することはなかったですJSF。私のために働く解決策は、stackoverflow.com/a/21279420/5788897

関連する問題