diff --git a/pom.xml b/pom.xml index 7ba082f..ae825c3 100644 --- a/pom.xml +++ b/pom.xml @@ -14,6 +14,30 @@ <version>0.0.1-SNAPSHOT</version> <name>8timerV200</name> <description>Demo project for Spring Boot</description> + + <profiles> + <profile> + <id>dev</id> + <properties> + <environment>dev</environment> + </properties> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + </profile> + <profile> + <id>test</id> + <properties> + <environment>test</environment> + </properties> + </profile> + <profile> + <id>pro</id> + <properties> + <environment>pro</environment> + </properties> + </profile> + </profiles> <properties> <java.version>1.8</java.version> @@ -342,6 +366,16 @@ <build> <finalName>8timer-api</finalName> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <includes> + <include>**/*.xml</include> + <include>**/*.yml</include> + </includes> + </resource> + </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> diff --git a/src/main/java/cn/timer/api/controller/LoginController.java b/src/main/java/cn/timer/api/controller/LoginController.java index 213ea8c..edd53e6 100644 --- a/src/main/java/cn/timer/api/controller/LoginController.java +++ b/src/main/java/cn/timer/api/controller/LoginController.java @@ -9,8 +9,11 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -52,6 +55,12 @@ import io.swagger.annotations.ApiOperation; public class LoginController { @Autowired + private Environment env; + + @Value("${configtest.patht}") + public String port; + + @Autowired private HttpSession session; @Autowired @@ -59,10 +68,16 @@ public class LoginController { @Autowired private QyzxEmpEntAssoMapper qyzxEmpEntAssoMapper; - + // @Autowired // private DataSourceTransactionManager transactionManager; + @GetMapping(value = "/testPro") + public Result<String> testPro() { + System.out.print(port); + return ResultUtil.success("configtest:" + port); + } + /** * 发送验证码 * diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 3feac67..e96b2cb 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,10 +1,10 @@ -#开发环境 +#生产环境 server: - port: 8080 + port: 8089 servlet: # context-path: /YoulinghrApiV100 session: - timeout: 2h # session会话过期时间 + timeout: 3600 # session会话过期时间 spring: servlet: multipart: @@ -13,20 +13,27 @@ spring: jpa: # 配置生成表 存储引擎InnoDB database-platform: org.hibernate.dialect.MySQL5InnoDBDialect - # database: - # open-in-view: false - #naming: + # database: + open-in-view: false + # naming: # spring boot jpa hibernate 根据实体类生成表以及字段的命名策略 # 无修改命名 org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl # 遇到大写字母 加”_”的命名 org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl - #physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + # physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl hibernate: ddl-auto: update show-sql: true datasource: - username: heimao - password: 999999 - url: jdbc:mysql://192.168.172.200:3306/youlingrc_8timer201?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL + # username: root + # password: youlingHR73! + username: youling8timer + password: (!0YouLing8Timer0!) + # username: tang + # password: Tang123456! + # url: jdbc:mysql://120.24.172.51:3306/youlingrc_tang?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL + url: jdbc:mysql://120.24.24.239:3306/8timer_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL + # url: jdbc:mysql://192.168.172.200:3306/youlingrc_8timer201?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL + # url: jdbc:mysql://db.hhlsz.com:3306/youlingrc_8timer201?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL driver-class-name: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource druid: @@ -110,11 +117,13 @@ pagehelper: logging: level: root: info - cn.timer.api.dao: debug + cn.timer.api.dao: error pattern: console: '--%p--%m%n' #swagger: # ui-config: # operations-sorter: method # 它提供了两个配置项:alpha和method,分别代表了按字母表排序以及按方法定义顺序排序 - \ No newline at end of file + +configtest: + patht: 'devPath-dev' \ No newline at end of file diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml index 4308f73..d3e3205 100644 --- a/src/main/resources/application-pro.yml +++ b/src/main/resources/application-pro.yml @@ -124,4 +124,6 @@ logging: #swagger: # ui-config: # operations-sorter: method # 它提供了两个配置项:alpha和method,分别代表了按字母表排序以及按方法定义顺序排序 - \ No newline at end of file + +configtest: + patht: 'devPath-pro' \ No newline at end of file diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml new file mode 100644 index 0000000..1fedc90 --- /dev/null +++ b/src/main/resources/application-test.yml @@ -0,0 +1,129 @@ +#生产环境 +server: + port: 8089 + servlet: + # context-path: /YoulinghrApiV100 + session: + timeout: 3600 # session会话过期时间 +spring: + servlet: + multipart: + max-file-size: 20MB + max-request-size: 20MB + jpa: + # 配置生成表 存储引擎InnoDB + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + # database: + open-in-view: false + # naming: + # spring boot jpa hibernate 根据实体类生成表以及字段的命名策略 + # 无修改命名 org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + # 遇到大写字母 加”_”的命名 org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + # physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + hibernate: + ddl-auto: update + show-sql: true + datasource: + # username: root + # password: youlingHR73! + username: youling8timer + password: (!0YouLing8Timer0!) + # username: tang + # password: Tang123456! + # url: jdbc:mysql://120.24.172.51:3306/youlingrc_tang?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL + url: jdbc:mysql://120.24.24.239:3306/8timer_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL + # url: jdbc:mysql://192.168.172.200:3306/youlingrc_8timer201?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL + # url: jdbc:mysql://db.hhlsz.com:3306/youlingrc_8timer201?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.alibaba.druid.pool.DruidDataSource + druid: + # 下面为连接池的补充设置,应用到上面所有数据源中 + # 初始化大小,最小,最大 + initial-size: 5 + min-idle: 5 + max-active: 20 + max-wait: 60000 # 配置获取连接等待超时的时间 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位是毫秒 + validation-query: SELECT 1 FROM DUAL + test-while-idle: true # 当连接空闲时,是否执行连接测试 + test-on-borrow: false # 当从连接池借用连接时,是否测试该连接 + test-on-return: false # 在连接归还到连接池时是否测试该连接 + # 打开PSCache,并且指定每个连接上PSCache的大小 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙 ,不能用log4j,不然报错:Failed to bind properties under 'spring.datasource.druid' to javax.sql.DataSource: + filters: stat,slf4j + use-global-data-source-stat: true + # 通过connectProperties属性来打开mergeSql功能;慢SQL记录 + #connect-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + # 配置监控服务器 + stat-view-servlet: + login-username: Tang + login-password: 123 + reset-enable: false + url-pattern: /druid/* + # 添加IP白名单 + #allow: + # 添加IP黑名单,当白名单和黑名单重复时,黑名单优先级更高 + #deny: + web-stat-filter: + # 添加过滤规则 + url-pattern: /* + # 忽略过滤格式 + exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*" + # 时间戳统一转换 + jackson: + date-format: yyyy-MM-dd HH:mm:ss + # spring boot启动打印横幅 配置 + banner: + charset: UTF-8 # Banner file encoding. + location: banner.txt # Banner text resource location. + image: + location: banner.gif # Banner image file location (jpg or png can also be used). + width: 76 # Width of the banner image in chars. + height: 76 # Height of the banner image in chars (default based on image height). + margin: 2 # Left hand image margin in chars. + invert: false # Whether images should be inverted for dark terminal themes. + + # mybatis-plus +mybatis-plus: + mapper-locations: classpath:mapping/**/*Mapper.xml # dao到xml文件映射 + type-aliases-package: cn.timer.api.bean # xml中#全局类名别名 + configuration: + #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # sql日志打印 + call-setters-on-nulls: true # Map做返回体时 字段值为null依然返回 + cache-enabled: true + global-config: + db-config: + #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID"; + #id-type: uuid + id-type: auto + #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断" + # field-strategy: not_null + #驼峰下划线转换 + table-underline: true + #逻辑删除配置 + #logic-delete-value: 0 + #logic-not-delete-value: 1 + # 分页插件 +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql + +#showSql +logging: + level: + root: info + cn.timer.api.dao: error + pattern: + console: '--%p--%m%n' + +#swagger: +# ui-config: +# operations-sorter: method # 它提供了两个配置项:alpha和method,分别代表了按字母表排序以及按方法定义顺序排序 + +configtest: + patht: 'devPath-test' \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a8b9b21..7b0ca8f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: pro + active: '@environment@' \ No newline at end of file