---
title: "Spring注构函数中外部属性注入"
author: "cloudstars"
date: "2014-10-31T10:57:10Z"
tags: []
categories: ["编程语言"]
slug: "spring"
draft: false
lastmod: "2014-10-31T10:57:10Z"
id: 2150034
url: "https://cloudstars.iteye.com/blog/2150034"
---

普通的属性可以这样注入：

@Value("${prop.name}")

 private String name;

 

构造函数的属性这样注入

@Autowired  
 public DemoConstructor(@Value("${prop.name}")String name) {

        ......  
 }