我正在使用MySQL作为数据库的Spring JPA应用程序.我确保加载所有spring-jpa库,hibernate和mysql-connector-java.
我正在运行一个mysql 5实例.以下是我的application.properties文件的摘录:
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.datasource.url=jdbc:mysql://localhost/mydatabase
spring.datasource.username=myuser
spring.datasource.password=SUPERSECRET
spring.datasource.driverClassName=com.mysql.jdbc.Driver
Run Code Online (Sandbox Code Playgroud)
执行集成测试时,spring正常启动但在创建hibernate SessionFactory时失败,但有异常:
org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111
Run Code Online (Sandbox Code Playgroud)
我认为我的方言应该是Mysql5Dialect,我也试过一个明确说明InnoDB,以及两个方言选项,它们不指示版本5.但我总是得到相同的'没有Dialect映射的JDBC类型:1111'消息.我的application.properties文件驻留在test/resources源文件夹中.它被JUnit Test跑者认可(我以前因为打字错误而得到例外).
属性我设置错了吗?我找不到关于这些属性名称的一些官方文档,但在这个stackoverflow答案中找到了一个提示:https://stackoverflow.com/a/25941616/1735497
期待您的回答,谢谢!
BTW该应用程序已使用弹簧启动.
我有一个spring MVC应用程序,当前放在src/main/java/resources/assets目录中有一堆css和js文件.
我阅读了Spring Docs和一些关于如何使用ResourceHandlerRegistry类为我的模板加载这些文件的教程.我特别认为本教程中的代码片段非常适合我的项目结构.
但是我的资源文件总是得到404.
这是我目前正在运行的Application/Configuration类:
@Configuration
@EnableAutoConfiguration
@ImportResource("/applicationContext.xml") // only used for jpa/hibernate
@EnableWebMvc
@ComponentScan(basePackages = "at.sustain.docutools.viewer.presentation")
public class Application extends WebMvcConfigurerAdapter {
public static void main(String args[]) {
SpringApplication.run(Application.class);
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/assets/**")
.addResourceLocations("classpath:/assets/");
registry.addResourceHandler("/css/**")
.addResourceLocations("/css/");
registry.addResourceHandler("/js/**")
.addResourceLocations("/js/");
}
}
Run Code Online (Sandbox Code Playgroud)
这里是我的HTML文件中使用的HEADer(放在资源/模板中):
<head>
<!-- local Stylesheet -->
<link href="css/style.css" rel="stylesheet" />
<!-- local Javascript files -->
<script src="js/general.js"></script>
<script src="js/xmlhttp.js"></script>
<!-- local Javascript libraries -->
<script src="js/lib/filter.js"></script>
<script src="js/lib/jquery.fs.zoomer.js"></script> …Run Code Online (Sandbox Code Playgroud)