http://phl.iteye.com/blog/1028218
由於eclipse的默認代碼風格很不實用,本文針對性的給出一些個性化設置。
統一代碼風格,是方便項目管理,為整個團隊建立良好的環境,減少閱讀成本;所有的強大的團隊協作,都是點滴積累的。
本文以eclipse3.6.2_javaee為例,其他版本是否兼容,暫不清楚.
1.【window】/【preferences】/【Java】/【code style】/【formatter】/【edit】
2.面板【indentation】
tab policy = spaces only
indentation size = 4
tab size = 4
他的作用是只適用空格縮進,不使用table,這樣可以去除不同平台下的txt識別問題
選中align fields in columns
他的作用是對其類中定義的屬性
3 面板【line wrapping】
maximum line width = 400
他的作用是不讓代碼自動換行
【method declarations】/【Parameters】
line wrapping policy = wrap all elements, exception first element if not necessary
選中 force split, even if line shorter than maxmum width
indentation policy = indent on column
這的作用是在方法聲明的時候,一個參數一行,尤其是spring mvc里一個方法十幾個參數的時候,看着非常爽
4 面板【comments】
去掉 Enable line comment formatting
他的含義是去掉單行注釋的格式化
5 若想直接導入模板,請見附件最新版本。