spring boot 多模块简单示例

  • 时间:
  • 浏览:0

包下新建MyBatisConfig.java

reference: http://www.jianshu.com/p/05c8be17c400a

有5个项目中用到了hive和hadoop,在用spring-boot搭个任务导入平台的以后,启动的以后报错了

dao模块是用来操作数据库的,创建包

项目右键-> 新建module.

项目社会形态look like this

reference: http://www.jianshu.com/p/69b9fbb97574

你你这个 是以后hadoop中的servlet-api的版本和spring-boot中的版本冲突了

hadoop中的是 2.5,而spring-boot中的是3.1,太多在pom.xml加入如下配置

the default port of tomcat server is 400400,

数据库操作

if you want to use another port ,

最近花了三天看spring-boot.简单记录下SpringBoot的多模块示例

本例中用的是method-1,完整版的pom.xml如下:

now, you want to use another version of jackson, you can add the follow dependency in you pom.xml

if occur ==IllegalStateException: No supported DataSource type found== error

run your application and you will see the filter is load.

数据库配置

直接加进去去parent,继承spring-boot的pom依赖

reference: https://springframework.guru/jackson-dependency-issue-spring-boot-maven/

then, each file's content are follow:

以后你项目中含你你这个 的父类,就非要用method-1中的继承了,另有5个给你另有5个来管理spring-boot的依赖

mybatis xml文件

if you want to add some filter in you web application

you can create application.properties under resources in web module.

for example:

the version of jackson in spring-boot-1.5.4.RELEASE is

now, you dao module's structure may look like this:

项目逻辑

reference: https://stackoverflow.com/questions/34790924/i-am-getting-datasource-not-supported-when-using-datasoucebuilder

项目有如下有5个模块

reference: https://stackoverflow.com/questions/31942908/spring-boot-application-with-hive-connection-doesnt-start-embedded-tomcat

这里才能 注意的,spring-boot以后加进去去了太多依赖的包,以后你想使用不同版本的库,给你用来移除,以后加进去去此人 版本的库

spring-boot-mult-module项目下配置spring-boot的依赖。

才能有你这个 最好的法律依据来引入spring-boot

then configure your filter in your ApplicationConfig.java

github: https://github.com/jjzhu-ncu/bg-study/tree/master/spring-boot/spring-boot-mult-module

web api,与前端交互

make sure the dependency of commons-dbcp, or tomcat-jdbc or hikaricp in your pom.xml file

define your filter

mybatis配置

数据库实体类 User

创建接口

finally, the structure of dao module may look like this:

在main文件夹下创建resources文件夹,并加进去去文件

then run all the tests and check the database to see whether or not the insert test is successful.

and add the follow property to change server port