spring boot注意事项
1.配置xml的文件位置
#类型别名配置,
mybatis.type-aliases-package=com.example.gbasetest.entity
#映射的文件路径
mybatis.mapper-locations=classpath*:mapper/*.xml
mybatis.configuration.call-setters-on-nulls=true
2.gbase的source源
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.url=jdbc:gbase://192.168.133.141:5258/abc
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
#spring.datasource.type=com.gbase.jdbc.jdbc2.optional.GBaseDataSource
#spring.datasource.type=com.gbase.jdbc.jdbc2.optional.GBaseDataSource
spring.datasource.driver-class-name=com.gbase.jdbc.Driver
spring.datasource.tomcat.test-while-idle=true
spring.datasource.tomcat.validation-query=SELECT 1
3.启动类加上mapper的扫描
@MapperScan({"com.example.gbasetest.mapper"})
@ComponentScan(basePackages = { "com.example.gbasetest.*"})
4.本地jar包如何用maven进行安装
mvn install:install-file -DgroupId=com.gbase -DartifactId=gbase-connector-java -Dversion=8.3.81.53-build55.2.1-bin -Dpackaging=jar -Dfile=/D:/code/jsabc-all/environment/gbase
/GBase_JDBC/gbase-connector-java-8.3.81.53-build55.2.1-bin.jar
5.pom配置
<dependency>
<groupId>com.gbase</groupId>
<artifactId>gbase-connector-java</artifactId>
<version>8.3.81.53-build55.2.1-bin</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
6.spring boot的几个核心依赖
springboot之核心依赖
#1.spring-boot-starter-parent(控制版本信息),好处:以后我们导入依赖默认是不需要写版本
#2.spring-boot-starter Spring Boot的核心启动器,包含了自动配置、日志和YAML
#3.spring-boot-starter-web web的场景,自动帮我们引入了web模块开发需要的相关jar包, 并且包含spring-boot-starter
#4. spring-boot-starter-test springboot程序测试依赖,如果是自动创建项目默认添加
最基础的两个依赖
<dependencies>
<!--springboot程序测试依赖,如果是自动创建项目默认添加-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--springboot web模块支持,自动帮我们引入了web模块开发需要的相关jar包-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
还不快抢沙发