NutzCN Logo
问答 springboot整合nutz 开启migration,就出现异常
发布于 225天前 作者 qq_2df9dd31 359 次浏览 复制 上一个帖子 下一个帖子
标签:

在springboot中使用了nutz-plugins-spring-boot-starter插件,数据库使用的是postgresql 连接池使用的是druid,当开启migration: true,就出现了如下异常

2018-04-08 21:19:33.463 DEBUG 5016 --- [           main] org.nutz.dao.util.Daos                   : migration Table 'sys_role' fail!

java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'ndex from sys_role', expect FROM, actual FROM pos 15, line 1, column 11, token FROM : show index from sys_role
	at com.alibaba.druid.wall.WallFilter.checkInternal(WallFilter.java:798) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.wall.WallFilter.connection_prepareStatement(WallFilter.java:251) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:473) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:929) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:122) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:473) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:349) ~[druid-1.1.6.jar:1.1.6]
	at org.nutz.dao.impl.jdbc.AbstractJdbcExpert.getIndexNames(AbstractJdbcExpert.java:476) ~[nutz-1.r.65.jar:1.r.65]
	at org.nutz.dao.util.Daos$4.invoke(Daos.java:790) ~[nutz-1.r.65.jar:1.r.65]
	at org.nutz.integration.spring.SpringDaoRunner._run(SpringDaoRunner.java:18) [nutz-integration-spring-1.r.65.jar:na]
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:82) [nutz-1.r.65.jar:1.r.65]
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240) [nutz-1.r.65.jar:1.r.65]
	at org.nutz.dao.util.Daos.migration(Daos.java:747) [nutz-1.r.65.jar:1.r.65]
	at org.nutz.dao.util.Daos.migration(Daos.java:965) [nutz-1.r.65.jar:1.r.65]
	at org.nutz.plugin.spring.boot.listener.NutzDataBaseIniter$2.invoke(NutzDataBaseIniter.java:48) [nutz-plugins-spring-boot-starter-1.r.65.jar:na]
	at org.nutz.plugin.spring.boot.listener.NutzDataBaseIniter$2.invoke(NutzDataBaseIniter.java:1) [nutz-plugins-spring-boot-starter-1.r.65.jar:na]
	at org.nutz.lang.Lang.each(Lang.java:1596) [nutz-1.r.65.jar:1.r.65]
	at org.nutz.lang.Lang.each(Lang.java:1561) [nutz-1.r.65.jar:1.r.65]
	at org.nutz.plugin.spring.boot.listener.NutzDataBaseIniter.create(NutzDataBaseIniter.java:44) [nutz-plugins-spring-boot-starter-1.r.65.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) [spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) [spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) [spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120) [spring-boot-test-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) [spring-test-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283) [surefire-junit4-2.18.1.jar:2.18.1]
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173) [surefire-junit4-2.18.1.jar:2.18.1]
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) [surefire-junit4-2.18.1.jar:2.18.1]
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128) [surefire-junit4-2.18.1.jar:2.18.1]
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203) [surefire-booter-2.18.1.jar:2.18.1]
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155) [surefire-booter-2.18.1.jar:2.18.1]
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) [surefire-booter-2.18.1.jar:2.18.1]
Caused by: com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'ndex from sys_role', expect FROM, actual FROM pos 15, line 1, column 11, token FROM
	at com.alibaba.druid.sql.parser.SQLParser.printError(SQLParser.java:284) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:421) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:81) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.wall.WallProvider.checkInternal(WallProvider.java:624) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.wall.WallProvider.check(WallProvider.java:578) ~[druid-1.1.6.jar:1.1.6]
	at com.alibaba.druid.wall.WallFilter.checkInternal(WallFilter.java:785) ~[druid-1.1.6.jar:1.1.6]
	... 69 common frames omitted


示例表结构如下 CREATE TABLE sys_role(
id VARCHAR(128),
role_name VARCHAR(128),
role_desc VARCHAR(128),
role_status VARCHAR(128),
create_time TIMESTAMP,
update_time TIMESTAMP,
CONSTRAINT sys_role_pkey PRIMARY KEY (id)
)

插件版本为1.r.65, 是对每一个数据库实体都会产生如上异常日志,, 新手 望指导一下啦~~

5 回复
ndex from sys_role

少了一个 i ?

来自炫酷的 NutzCN

那是driud的SQL防火墙的SQL解析器的bug, 跟nutz没关系

加个配置项,禁用索引增减才行

@wendal 大佬 找不到这个增减索引的配置啊? 能否告知一下啊~~

我的意思是springboot插件需要新增个配置项,让用户可以选择是否迁移索引

你可以看看代码,提交个pull request哦

添加回复
请先登陆
回到顶部