java中一些常用的配置

application.yml下的一些公共的配置

#server端口配置
server:
  port: 8080
 

#数据库连接配置
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/mybatis-xml?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8
    username: root
    password: 123456

    #数据源配置
    type: com.alibaba.druid.pool.DruidDataSource
    driverClassName: com.mysql.cj.jdbc.Driver
  #HTML配置
  thymeleaf:
    prefix: classpath:/templates/
    suffix: .html
  #热部署配置

  devtools:
    livereload:
      enabled: true  #是否支持livereload
    restart:
      enabled: true  #是否支持热部署

#Mybatis配置
mybatis:
  config-location: classpath:config/mybatis-config.xml  #mybatis配置文件位置
  mapper-locations: classpath:mapper/*.xml       #mapper.xml 文件地址
  type-aliases-package: com.thinkingcao.springboot.entity #实体类别名
#日志配置
logging:
  level:
    com.thinkingcao.springboot.mapper: debug   #项目日志配置
    org.springframework.web: DEBUG   #Spring框架日志配置

mybatis的公共头配置

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 为这个mapper指定一个唯一的namespace,namespace的值习惯上设置成包名+sql映射文件名,这样就能够保证namespace的值是唯一的
例如namespace="me.gacl.mapping.userMapper"就是me.gacl.mapping(包名)+userMapper(userMapper.xml文件去除后缀)
 -->
<mapper namespace="me.gacl.mapping.userMapper">
    <!-- 在select标签中编写查询的SQL语句, 设置select标签的id属性为getUser,id属性值必须是唯一的,不能够重复
    使用parameterType属性指明查询时使用的参数类型,resultType属性指明查询返回的结果集类型
    resultType="me.gacl.domain.User"就表示将查询结果封装成一个User类的对象返回
    User类就是users表所对应的实体类
    -->
   
   
</mapper>

log4j.properties

# Global logging configuration
log4j.rootLogger=DEBUG, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

db.properties

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/表名称?useUnicode=true&characterEncoding=utf8
username=root
password=123456
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值