打算把detectx迁移,毕竟springboot更适合它,
首先我是用的快速建立的项目,springboot版本为 1.5.19.RELEASE ,官网查了下,这个是GA稳定生产环境版本
然后如果要导入starter,我发现得看maven仓库的依赖,也就是starter的springboot依赖要和我用的springboot版本相同才能导入(别的版本的starter maven好像是不会自动导入依赖的)
pom.xml 中,这些插件例如 mysql-connector-java 这类的依赖,首先得在 <dependencies></dependencies>标签中进行导入,插件这边才能响应到
然后mybatis逆向工程如果想成功运行,不出现下面这样的异常,mybatis-generator-core 的版本就必须为 1.3.6
mybatis-generator-maven-plugin:1.3.7:generate: java.lang.NoSuchMethodError
pom.xml:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.38</version> </dependency> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.6</version> </dependency> </dependencies> <executions> <execution> <id>Generate MyBatis Artifacts</id> <phase>package</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <verbose>true</verbose> <overwrite>true</overwrite> <configurationFile> src/main/resources/mbg.xml</configurationFile> </configuration> </plugin> </plugins> </build> </project>
2.如果想要使用xsd,就必须想导入包含有这个xsd文件的pom依赖
3.启用jsp
<dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <scope>compile</scope> </dependency>
application.properties
spring.mvc.view.prefix=/ spring.thymeleaf.cache=false spring.thymeleaf.enabled = false
4.解决中文乱码问题:
spring.http.encoding.force=true spring.http.encoding.charset=UTF-8 spring.http.encoding.enabled=true server.tomcat.uri-encoding=UTF-8
5.整合mybatis
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/detectx?characterEncoding=UTF-8 spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.jdbc.Driver mybatis.mapper-locations=classpath:mapper/*.xml
注:dao下的mapper接口都需要 @Mapper 注解
注:如果 @Autowired 不到mapper就用 @Resource
原文地址:https://www.cnblogs.com/kinome/p/10393316.html
时间: 2024-10-28 23:49:58