Springboot2集成minidao持久层

Springboot2集成minidao持久层

这里采用springboot版本号: 2.0.4.RELEASE
minidao已经提供自定义starter,集成非常简单,直接pom引入minidao-spring-boot-starter依赖即可

集成步骤:

  • 第一步: pom引入starter依赖包
<dependency>
		<groupId>org.jeecgframework</groupId>
		<artifactId>minidao-spring-boot-starter</artifactId>
		<version>1.6.7.RELEASE</version>
</dependency>

此starterd对应的minidao最新版本 1.6.7 默认提供了mysql的依赖。

  • 第二步:配置minidao的配置参数 (application.properties 或者 application.yml)
   minidao:
     base-package: com.springBoot.*
     db-type: mysql
     show-sql: true

第三步: 配置springjdbc所需数据源 ( application.yml)

 spring:       
    datasource:
        url: jdbc:mysql://localhost:3306/minidao-pe
        username: root
        password: root
        driver-class-name: com.mysql.jdbc.Driver

通过以上三步,minidao集成完毕。

参考源码下载: https://download.csdn.net/download/zhangdaiscott/10799483
技术交流群:325978980

Minidao常见配置参数说明:

参数名 用途 默认值
base-package minidao扫描路径 *
db-type 数据库类型 mysql,其他配置: mysql/postgresql/oracle/sqlserver
show-sql 是否打印sql true
empty-interceptor minidao拦截器的bean名字
keyType 是使用什么字母做关键字Map的关键字 默认值origin 即和sql保持一致,lower小写(推荐),upper 大写 origin
展开阅读全文

Error creating bean with name 'sessionFactory'

08-23
项目环境:jdk1.8.0_101 tomcat8 maven3.39 eclipse spring4.1.7 hibernate4.0.5 _从svn上检出的项目报这个,在同事电脑上跑的好好的 报错日志: 八月 23, 2017 2:51:46 下午 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseDao2Impl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.hulftchina.dao.base.impl.BaseDao2Impl.sessionFactory2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-hibernate.xml]: Invocation of init method failed; nested exception is java.lang.ClassFormatError: Invalid field attribute index 25956 in class file org/hibernate/mapping/Constraint at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397) 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) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.hulftchina.dao.base.impl.BaseDao2Impl.sessionFactory2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-hibernate.xml]: Invocation of init method failed; nested exception is java.lang.ClassFormatError: Invalid field attribute index 25956 in class file org/hibernate/mapping/Constraint at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ... 22 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-hibernate.xml]: Invocation of init method failed; nested exception is java.lang.ClassFormatError: Invalid field attribute index 25956 in class file org/hibernate/mapping/Constraint at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1120) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1044) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533) ... 24 more Caused by: java.lang.ClassFormatError: Invalid field attribute index 25956 in class file org/hibernate/mapping/Constraint at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2541) at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:858) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1301) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2541) at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:858) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1301) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166) at org.hibernate.mapping.Table.createForeignKey(Table.java:661) at org.hibernate.mapping.Table.createForeignKey(Table.java:652) at org.hibernate.mapping.SimpleValue.createForeignKeyOfEntity(SimpleValue.java:159) at org.hibernate.mapping.ManyToOne.createForeignKey(ManyToOne.java:61) at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:557) at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:117) at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1598) at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1521) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1422) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1930) at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570) ... 34 more_ 八月 23, 2017 2:51:46 下午 org.apache.catalina.core.StandardContext startInternal 严重: One or more listeners failed to start. Full details will be found in the appropriate container log file 八月 23, 2017 2:51:46 下午 org.apache.catalina.core.StandardContext startInternal 严重: Context [/pension] startup failed due to previous errors 八月 23, 2017 2:51:46 下午 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext_
©️2020 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值