项目结构:
其中,coreservice包含DAO层代码,采用Mybatis框架,webservice为web层,springboot启动类包含其中,webservice依赖coreservice,打包的时候要注意以下几点:
(1)主pom文件不要包含build标签
(2)web模块的pom文件中包含build内容!
webservice中的build内容:
org.springframework.boot
spring-boot-maven-plugin
shangfei.SpringBootStartApplication
repackage
org.apache.maven.plugins
maven-compiler-plugin
1.8
1.8
org.apache.maven.plugins
maven-surefire-plugin
2.19.1
true
(3)coreservice中的build内容
models
*.txt
src/main/resources
**/*.xml
*.xml
*.properties
org.apache.maven.plugins
maven-compiler-plugin
1.8
1.8
(4)打包成Jar包之后一直连接不了数据库,后来在web层中的application.properties中要加入连接数据库配置
按道理来说webservice依赖的是coreservice,coreservice中已经包含了mybatis的配置文件,不用再额外配置了,这里一直没弄明白,但是加上去就连接正常了