0
点赞
收藏
分享

微信扫一扫

SpringCloud配置acyive的profiles


   application.yml

spring:
profiles:
active: pre

  application-dev.yml

junzizhibang:
url: dev.junzizhibang.com
@RestController
public class IndexController {
@Value("${junzizhibang.url}")
private String url;

@RequestMapping("/getUrl")
public String getUrl() {
return url;
}
}

JDBC的SPringCloud的配置

@Service
public class UserService {

@Autowired
private JdbcTemplate jdbcTemplate;


public boolean addUser(String userName, Integer age) {
int update = jdbcTemplate.update("insert into users values(null,?,?);", userName, age);
return update > 0 ? true : false;
}
}

yaml的数据库配置:

spring:
datasource:
url: jdbc:mysql://localhost:3306/test
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver



举报

相关推荐

0 条评论