关于minidao1.6.2最新版本与spring boot整合bug反馈
本帖最后由 veteran123 于 2018-4-13 00:48 编辑minidao 在上一个项目中使用起来非常得心应手。
这次使用了minidao最新版本1.6.2,在整合spring boot 时发现一个问题,就是根本无法读到sql文件,@Sql注解可以正常使用。
下面是maven配置 <dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
</dependency>
<dependency>
<groupId>org.jeecgframework</groupId>
<artifactId>freemarker-null</artifactId>
<version>2.3.19</version>
</dependency>
<dependency>
<groupId>org.jeecgframework</groupId>
<artifactId>minidao-pe</artifactId>
<version>1.6.2</version>
</dependency>spring boot 的配置代码 @Bean(name = "miniDaoHandler")
public MiniDaoBeanScannerConfigurer getMiniDaoBeanScannerConfigurer(){
MiniDaoBeanScannerConfigurer miniDaoBeanScannerConfigurer = new MiniDaoBeanScannerConfigurer();
miniDaoBeanScannerConfigurer.setKeyType("lower");
miniDaoBeanScannerConfigurer.setFormatSql(true);
miniDaoBeanScannerConfigurer.setShowSql(true);
miniDaoBeanScannerConfigurer.setDbType("mysql");
miniDaoBeanScannerConfigurer.setBasePackage("com.movitech.cyperion");
miniDaoBeanScannerConfigurer.setEmptyInterceptor(new MinidaoInterceptor());
return miniDaoBeanScannerConfigurer;
}直接写sql语句在@Sql注解里面没有问题@MiniDao
public interface DimensionDao {
@Arguments({"name"})
@Sql("select * from mc_dimension\n" +
"<#if name ?exists&& name?length gt 0 >\n" +
"\twhere mc_dimension.name = :name\n" +
"</#if>")
@ResultType(Dimension.class)
List<Dimension> getAllDimension( String name);
}
如果把sql内容移到sql文件中,就会读不到sql模板错误
错误信息:
解决方案在pom文件中加 <resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.sql</include>
</includes>
</resource>
</resources> 各位大神可以自己整一个看看呢 我参考了下minidao常见错误。把1.6.2升级到1.6.3了。还是不行。
http://www.jeecg.org/forum.php?mod=viewthread&tid=1830&extra=page%3D1
这个帖子说
115. minidao 提示sql文件不存在,实际sql存在。
问题原因: 此为minidao提示不准确问题,真正问题是sql模板freemarker语法错误。
解决方案:可以引用minidao最新版1.6.3
最简单的sql语句了,应该不是语法错误引起了吧。
@EnableAutoConfiguration(exclude = { FreeMarkerAutoConfiguration.class })
@ImportResource(locations={"classpath:spring-minidao.xml"})
@EnableAutoConfiguration(exclude = { FreeMarkerAutoConfiguration.class })
@ImportResource(locations={"classpath:spring-minidao.xml"})
这两个我也加了,还是没用 你看看项目编译 sql文件打进去了吗 admin 发表于 2018-4-12 09:25 static/image/common/back.gif
你看看项目编译 sql文件打进去了吗
我是run main方法啊,不是打包 无论你那种方式,你需要确认*.sql文件在不在class里面 看看这个http://www.jeecg.org/forum.php?mod=viewthread&tid=5458&extra=page%3D7 admin 发表于 2018-4-12 14:05 static/image/common/back.gif
无论你那种方式,你需要确认*.sql文件在不在class里面
提醒我了。找了下确实*.sql文件不在classpath里面。pom文件中要加 <resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.sql</include>
</includes>
</resource>
</resources>就可以解决了。
页:
[1]
2