In the previous post you could read about separate Spring Boot builds for a local development machine and public environments. It’s highly possible that in addition to such setup you would like to load different Spring properties files based on the a…
spring.profiles.active=@profiles.active@ ,其实是配合 maven profile进行选择不同配置文件进行启动. 当执行 mvn clean package -P test 命令时, @profiles.active@ 会替换成 test 打开 jar包,即可看到:   实战 1.构建一个springboot 项目 这里使用idea进行构建的,这个过程省略 2.pom文件配置 <profiles> <profile> <!-- 生产环境…
现在在的公司用spring.profiles.active=@profiles.active@ 当我看到这个的时候,一脸蒙蔽,这个@ 是啥意思. 这里其实是配合 maven profile进行选择不同配置文件进行开发 实战 1.构建一个springboot 项目 这里使用idea进行构建的,这个过程省略 2.pom文件配置 <profiles> <profile> <!-- 生产环境 --> <id>prod</id> <propertie…
错误信息: java.lang.IllegalStateException: Active Spring transaction synchronization or active JTA transaction with specified [javax.transaction.TransactionManager] required at org.springframework.jdbc.support.lob.LobCreatorUtils.registerTransactionSynch…
Spring Aop中@pointCut的用法,格式:execution(modifiers-pattern? ret-type-pattern declaring-type-pattern? name-pattern(param-pattern)throws-pattern?)pattern分别表示: 修饰符匹配(modifier-pattern?) 返回值匹配(ret-type-pattern)可以为*表示任何返回值,全路径的类名等 类路径匹配(declaring-type-pattern?…
spring 中配置sessionFactory及用法 方法一: 1.在Spring的applicationContext.xml中配置bean <!-- 启用注解注入  -->       <context:annotation-config />       <!-- spring扫描的包 -->       <context:component-scan base-package="com.iven"/>             …
Spring中JdbcTemplate的基础用法 1.在DAO中使用JdbcTemplate 一般都是在DAO类中使用JdbcTimplate,在XML配置文件中配置好后,可以在DAO中注入即可. 在Spring配置文件中配置DAO一般分为4个步骤: 1.定义DataSource 2.定义JdbcTimplate 3.声明一个抽象的<bean>,以便所有的DAO复用配置JdbcTimplate属性的配置 4.配置具体的DAO 1 <!-- 配置事务管理器 --><!-- 扫描…
本文不再更新,可能存在内容过时的情况,实时更新请移步我的新博客:全面解析Spring中@ModelAttribute注解的用法: @ModelAttribute注解用于将方法的参数或方法的返回值绑定到指定的模型属性上,并返回给Web视图.具体用法整理如下: 1.@ModelAttribute注释方法 下面的1),2),3)这三个例子类似,被@ModelAttribute注解注释的方法会在此controller每个方法执行前被执行,因此对于一个controller映射多个URL的用法来说,要谨慎使…
结论:通用项配置在applicaton.yml,区别环境配置在application-{profile}.yml中 一直不知道这个参数要不要配,配了有什么用,今天搭一个工程来检验 此项作用:用来区分不同环境配置 application-dev.yml 开发环境 application-test.yml 测试环境 application-prod.yml 生产环境 applicaton.yml(通用项配置)用spring.profile.active=dev来决定启用上面的哪个环境配置文件(不同环…
1. 在pom.xml添加 <profiles> <profile> <id>dev</id> <properties> <environment>dev</environment> </properties> </profile> <profile> <id>prod</id> <properties> <environment>prod…