锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久亚洲国产成人精品性色,亚洲AV无码国产一区二区三区 ,亚洲国产精品狼友中文久久久http://www.tkk7.com/wshao/category/54088.htmlzh-cnTue, 25 Mar 2014 09:07:12 GMTTue, 25 Mar 2014 09:07:12 GMT60浣跨敤Spring mvc 鍒╃敤java鐨勫弽灝勬妧鏈紝鏉ユ壂鎻忓搴斿寘涓嬬殑娉ㄨВ璇鋒眰url 緇熶竴淇濆瓨鍦ㄦ暟鎹簱涓?/title><link>http://www.tkk7.com/wshao/archive/2014/03/25/411455.html</link><dc:creator>鍗堝悗鏄熸湡鍗?/dc:creator><author>鍗堝悗鏄熸湡鍗?/author><pubDate>Tue, 25 Mar 2014 06:54:00 GMT</pubDate><guid>http://www.tkk7.com/wshao/archive/2014/03/25/411455.html</guid><wfw:comment>http://www.tkk7.com/wshao/comments/411455.html</wfw:comment><comments>http://www.tkk7.com/wshao/archive/2014/03/25/411455.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/wshao/comments/commentRss/411455.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/wshao/services/trackbacks/411455.html</trackback:ping><description><![CDATA[<div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">浠呭  <wbr>@requestMapping("/xxxx/鍏朵粬鍙傛暟")  <wbr>鐨勬牸寮?/div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>package cc.wshao.springmvc.util;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">import java.io.File;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">import java.lang.reflect.Method;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">import java.net.URL;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">import org.springframework.context.ApplicationContext;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">import org.springframework.context.support.ClassPathXmlApplicationC<wbr>ontext;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">import org.springframework.stereotype.Controller;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">import org.springframework.web.bind.annotation.RequestMapping;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">import cc.wshao.springmvc.service.RightService;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">public class RegRightUtils {</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">private static final String rootUrl = "/spring";</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">private static RightService rightService;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">public static void main(String[] args) throws Exception {</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">ApplicationContext context = new ClassPathXmlApplicationC<wbr>ontext("beans.xml");</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr> rightService = context.getBean(RightService.class);</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">ClassLoader classLoader = RegRightUtils.class.getClassLoader();</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">URL url = classLoader.getResource("com/er07/book/springmvc/controller");</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">String rootPath = url.getPath().toString();</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">File rootFile = new File(rootPath);</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">File [] files = rootFile.listFiles();</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">for(File f: files) {</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">System.err.println(f.getName());</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">String className = f.getName().substring(0, f.getName().indexOf(".class"));</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">Class clazz = Class.forName("com.er07.book.springmvc.controller."+className);</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">parseClass(clazz);  <wbr>//瑙f瀽  <wbr>鍑簎rl</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">}</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">}</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">public  <wbr>static void parseClass(Class clazz) {</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">if(clazz.isAnnotationPresent(Controller.class)) {  <wbr> //鏄惁涓轟竴涓猚ontroller ? <wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">String classUrl ="";</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>if(clazz.isAnnotationPresent(RequestMapping.class)) {</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>RequestMapping requestMapping_clazz = (RequestMapping) clazz.getAnnotation(RequestMapping.class);</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr> classUrl = requestMapping_clazz.value()[0];</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr> <wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr> if(classUrl.equals("/")) {  <wbr>//濡傛灉鏄?/" 鐨勮瘽  <wbr>鍒剁┖  <wbr>  <wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr> classUrl ="";</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr> }</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>}</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>Method [] ms = clazz.getDeclaredMethods();</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>for(Method m :ms) {</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>if(m.isAnnotationPresent(RequestMapping.class)) {</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>RequestMapping requestMapping_method = m.getAnnotation(RequestMapping.class);</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>String methodUrl = requestMapping_method.value()[0];</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>  <wbr>int  <wbr>index = methodUrl.indexOf("/");</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>  <wbr>index = methodUrl.indexOf("/",index+1);</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>  <wbr>if(index!=-1) {  <wbr>//濡傛灉瀛樺湪 鍒欒繘琛屾埅鍙栧墠闈㈢殑url <wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>  <wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>  <wbr> methodUrl = methodUrl.substring(0, index);</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>  <wbr>}</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>String resultUrl = rootUrl+classUrl+methodUrl;</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>rightService.appendRightByUrl(resultUrl);</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>}</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"> <wbr>}</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">}</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">}</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">}</div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;">//瀹炵幇鏂規硶錛?nbsp;<wbr></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"></div><div style="color: #464646; font-family: simsun; background-color: #bcd3e5;"><div>public void appendRightByUrl(String url) {</div><div>//鏌ヨ 姝rl 鍦ㄦ暟鎹簱涓槸鍚﹀瓨鍦? <wbr>姝ゆ潈闄?/div><div>String hql = "from Right where rightUrl =?";</div><div>Right r = (Right) this.rightDao.uniqueResult(hql, url);</div><div>if(r==null) { //涓嶅瓨鍦?, 鎻掑叆鏁版嵁搴撲腑</div><div>Right newRight = new Right();</div><div>newRight.setRightUrl(url);</div><div>this.saveOrUpdateRight(newRight);</div><div>}</div><div>}</div></div><img src ="http://www.tkk7.com/wshao/aggbug/411455.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wshao/" target="_blank">鍗堝悗鏄熸湡鍗?/a> 2014-03-25 14:54 <a href="http://www.tkk7.com/wshao/archive/2014/03/25/411455.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Spring鐨凧NDI鏁版嵁婧愯繛鎺ユ睜閰嶇疆紺轟緥鍙奡pring瀵笿NDI瀹炵幇鍒嗘瀽http://www.tkk7.com/wshao/archive/2013/12/31/408290.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 06:28:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408290.htmlhttp://www.tkk7.com/wshao/comments/408290.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408290.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408290.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408290.html闃呰鍏ㄦ枃

]]>
java鐨勬墦鍖卝ar,war,ear鍖呯殑浣滅敤錛屽尯鍒紝鎵撳寘鏂瑰紡錛堟湰鏂囨墦jar錛?/title><link>http://www.tkk7.com/wshao/archive/2013/12/31/408284.html</link><dc:creator>鍗堝悗鏄熸湡鍗?/dc:creator><author>鍗堝悗鏄熸湡鍗?/author><pubDate>Tue, 31 Dec 2013 06:22:00 GMT</pubDate><guid>http://www.tkk7.com/wshao/archive/2013/12/31/408284.html</guid><wfw:comment>http://www.tkk7.com/wshao/comments/408284.html</wfw:comment><comments>http://www.tkk7.com/wshao/archive/2013/12/31/408284.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/wshao/comments/commentRss/408284.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/wshao/services/trackbacks/408284.html</trackback:ping><description><![CDATA[<p style="text-indent: -21pt; margin: 0cm 0cm 0pt 21pt"><span>涓銆?/span>java<span style="font-family: 瀹嬩綋">鐨勬墦鍖?/span>jar,war,ear<span style="font-family: 瀹嬩綋">鍖呯殑浣滅敤錛屽尯鍒紝鎵撳寘鏂瑰紡</span>.</p> <p style="text-indent: -21pt; margin: 0cm 0cm 0pt 42pt"><span>a)<span style="font: 7pt 'Times New Roman'">         </span></span><span style="font-family: 瀹嬩綋">浣滅敤涓庡尯鍒?/span></p> <p style="text-indent: -63pt; margin: 0cm 0cm 0pt 63pt"><span style="font: 7pt 'Times New Roman'">                         i.<span style="font: 7pt 'Times New Roman'">              </span></span>jar: <span style="font-family: 瀹嬩綋">閫氬父鏄紑鍙戞椂瑕佸紩鐢ㄩ氱敤</span>(JAVA)<span style="font-family: 瀹嬩綋">綾伙紝鎵撴垚鍖呬究浜庡瓨鏀劇鐞?/span></p> <p style="text-indent: -63pt; margin: 0cm 0cm 0pt 63pt"><span style="font: 7pt 'Times New Roman'">                       ii.<span style="font: 7pt 'Times New Roman'">              </span></span>war: <span style="font-family: 瀹嬩綋">鏄仛濂戒竴涓?/span>(web)<span style="font-family: 瀹嬩綋">搴旂敤鍚庯紝閫氬父鏄綉绔欙紝鎵撴垚鍖呴儴緗插埌瀹瑰櫒涓?/span></p> <p style="text-indent: -63pt; margin: 0cm 0cm 0pt 63pt"><span style="font: 7pt 'Times New Roman'">                      iii.<span style="font: 7pt 'Times New Roman'">              </span></span>ear: <span style="font-family: 瀹嬩綋">浼佷笟綰у簲鐢紝瀹為檯涓?/span>EAR<span style="font-family: 瀹嬩綋">鍖呬腑鍖呭惈</span>WAR<span style="font-family: 瀹嬩綋">鍖呭拰鍑犱釜浼佷笟綰ч」鐩殑閰嶇疆鏂囦歡鑰屽凡錛屼竴鑸湇鍔″櫒閫夋嫨</span>WebSphere<span style="font-family: 瀹嬩綋">絳夛紝閮戒細浣跨敤</span>EAR<span style="font-family: 瀹嬩綋">鍖呫傞氬父鏄?/span>EJB<span style="font-family: 瀹嬩綋">鎵撴垚</span>ear<span style="font-family: 瀹嬩綋">鍖呫?/span></p> <p style="text-indent: -21pt; margin: 0cm 0cm 0pt 42pt"><span>b)<span style="font: 7pt 'Times New Roman'">         </span></span><span style="font-family: 瀹嬩綋">鎵撳寘鏂瑰紡</span></p> <p style="text-indent: -63pt; margin: 0cm 0cm 0pt 63pt"><span style="font: 7pt 'Times New Roman'">                         i.<span style="font: 7pt 'Times New Roman'">              </span></span><span style="font-family: 瀹嬩綋">鎵鏈夌殑鍖呴兘鏄敤</span>jar<span style="font-family: 瀹嬩綋">鎵撶殑錛屽彧涓嶈繃鐩爣鏂囦歡鐨勬墿灞曞悕涓嶄竴鏍?/span></p> <p style="text-indent: -63pt; margin: 0cm 0cm 0pt 63pt"><span style="font: 7pt 'Times New Roman'">                       ii.<span style="font: 7pt 'Times New Roman'">              </span></span><span style="font-family: 瀹嬩綋">涔熷彲浠ョ敤</span>Ant<span style="font-family: 瀹嬩綋">鏉ュ畨鎴愭瀯寤?/span></p> <p style="text-indent: -21pt; margin: 0cm 0cm 0pt 42pt"><span>c)<span style="font: 7pt 'Times New Roman'">         </span></span><span style="font-family: 'simsun','serif'">JET</span><span style="font-family: 瀹嬩綋">緙栬瘧鎴?/span><span style="font-family: 'simsun','serif'">EXE</span></p> <p style="text-indent: -63pt; margin: 0cm 0cm 0pt 63pt"><span style="font: 7pt 'Times New Roman'">                         i.<span style="font: 7pt 'Times New Roman'">              </span></span>JET<span>   </span><span style="font-family: 瀹嬩綋">鏄鐢ㄩ挶涔扮殑錛岃屼笖鎹</span><span>   JET   </span><span style="font-family: 瀹嬩綋">涔熶笉鏄兘鎶婃墍鏈夌殑</span><span>   Java   </span><span style="font-family: 瀹嬩綋">紼嬪簭閮界紪璇戞垚鎵ц鏂囦歡錛屾ц兘涔熻鎵撲簺鎶樻墸銆傛墍浠ワ紝浣跨敤鍒朵綔鍙墽琛?/span><span>   JAR   </span><span style="font-family: 瀹嬩綋">鏂囦歡鍖呯殑鏂規硶灝辨槸鏈浣抽夋嫨浜嗭紝浣曞喌瀹冭繕鑳戒繚鎸?/span><span>   Java   </span><span style="font-family: 瀹嬩綋">鐨勮法騫沖彴鐗規с?/span></p><br /><br />浜屻佸疄渚?br /><br />鏂規硶涓錛氭垜鐜板湪鏈塼est/A.java<br />    閬撶悊铏界劧綆鍗曪紝浣嗘槸鍦ㄨ繖榪囩▼涓繕鏄湁寰堝緇嗚妭闇瑕佹敞鎰忕殑錛屽摢涓涓粏鑺傛敞鎰忎笉鍒幫紝鎿嶄綔閮戒笉浼氭垚鍔熴?br /> <div align="center"> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"> <div align="left"><span style="color: #0000ff">package</span><span style="color: #000000"> test;<br /></span><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span><span style="color: #000000"> A{<br />    </span><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span><span style="color: #000000"> main(String args[]){<br />        System.out.println(</span><span style="color: #000000">"</span><span style="color: #000000">test java</span><span style="color: #000000">"</span><span style="color: #000000">);<br />    }<br />}</span></div></div></div>    鍐欏ソ鍚庯紝淇濆瓨涓篈.java錛屽瓨鍦―:\Java\jdk1.6\test_jar\test\鐩綍涓嬮潰錛屾墦寮cmd錛岃繘鍏ヨ繖涓洰褰曪紝鍗矰:\Java \jdk1.6\test_jar\test\鐒跺悗鐢╦avac鍛戒護緙栬瘧錛屼細鐢熸垚涓涓狝.class鏂囦歡錛屾鏃剁被鐨勭紪鍐欏伐浣滃凡緇忓畬鎴愩?br /><br />    2錛屽湪D:\Java\jdk1.6\test_jar鐩綍涓嬫柊寤轟竴涓枃浠跺すMETA-INF錛屽啀鏂板緩mainclass.mf鏂囦歡錛屽湪鍏朵腑鍐欏叆涓嬮潰涓琛屼俊鎭?br />    Main-Class: com/hp/HelloWorld<br />    榪欎竴鍙ユ湁涓や釜娉ㄦ剰鐨勫湴鏂癸紝棣栧厛琛屽熬瑕佹湁鍥炶濺鎹㈣錛涘叾嬈?#8220;:”鍜?#8220;com”涔嬮棿瑕佹湁涓涓┖鏍箋?br />    榪欎竴琛屼俊鎭殑浣滅敤鏄爣鏄庝富綾匯?br /><br />    3錛屾渶鍚庡氨鏄敓鎴恓ar鍖呭茍嫻嬭瘯浜嗭紝鍦╟md涓繘鍏:\Java\jdk1.6\test_jar鐩綍錛岃緭鍏ヤ笅鍒楀懡浠?nbsp;   <br />    jar cvfm test.jar META-INF/mainclass.mf test/A.class(<strong>榪欐槸鎸囧畾鏂囦歡錛屽綋鐒朵篃鍙互test鎸囧悜鏂囦歡澶?<br /></strong>    涓婅堪鍛戒護鎵ц鎴愬姛鐨勮瘽錛屼細鎻愮ず“鏍囨槑娓呭崟錛坢anifest錛?..”錛?br />    鐒跺悗鍐嶅湪褰撳墠鐩綍涓嬭緭鍏ava -jar test.jar 鍛戒護錛屽彲浠ョ湅鍒?#8220;test java”銆?nbsp;<br /> <br /><br /><br />鏂規硶浜岋細<br />    鐢ㄧ畝鍗曠殑jar -cvf test.jar    test鐩綍,jar浼氳嚜鍔ㄧ敓鎴怣ETA-INF/mainclass.mf錛屾垜浠彧闇瑕佸湪閲岄潰鍘誨姞涓鍙?nbsp;Main-Class: com/hp/HelloWorld<br />灝卞彲浠ヤ簡<br /><br /><br /><br />鏂規硶涓夛細myeclipse宸ュ叿銆錛?strong>鎺ㄨ崘</strong>錛?br />    鍙沖嚮欏圭洰--Export--Jar File-瑕侀夋嫨Main-Class<br /><br />鏂規硶鍥涳細ant<img src ="http://www.tkk7.com/wshao/aggbug/408284.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wshao/" target="_blank">鍗堝悗鏄熸湡鍗?/a> 2013-12-31 14:22 <a href="http://www.tkk7.com/wshao/archive/2013/12/31/408284.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>妗嗘灦Quart鍦↗ava涓換鍔¤皟搴︾殑浣跨敤http://www.tkk7.com/wshao/archive/2013/12/31/408277.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 06:13:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408277.htmlhttp://www.tkk7.com/wshao/comments/408277.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408277.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408277.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408277.htmlQuartz妗嗘灦鏄竴涓叏鍔熻兘銆佸紑婧愮殑浠誨姟璋冨害鏈嶅姟錛屽彲浠ラ泦鎴愬嚑涔庝換浣曠殑java搴旂敤紼嬪簭—浠庡皬鐨勫崟鐗囨満緋葷粺鍒板ぇ鍨嬬殑鐢靛瓙鍟嗗姟緋葷粺銆俀uartz鍙互鎵ц涓婂崈涓婁竾鐨勪換鍔¤皟搴︺?/p>

銆銆鏍稿績姒傚康

銆銆Quartz鏍稿績鐨勬蹇碉細scheduler浠誨姟璋冨害銆丣ob浠誨姟銆乀rigger瑙﹀彂鍣ㄣ丣obDetail浠誨姟緇嗚妭

銆銆Job浠誨姟錛氬叾瀹濲ob鏄帴鍙o紝鍏朵腑鍙湁涓涓猠xecute鏂規硶錛?/p>

銆銆package org.quartz;

銆銆public abstract interface Job

銆銆{

銆銆public abstract void execute(JobExecutionContext paramJobExecutionContext)

銆銆throws JobExecutionException;

銆銆}

銆銆鎴戜滑寮鍙戣呭彧瑕佸疄鐜版鎺ュ彛錛屽疄鐜癳xecute鏂規硶鍗沖彲銆傛妸鎴戜滑鎯沖仛鐨勪簨鎯咃紝鍦╡xecute涓墽琛屽嵆鍙?/p>

銆銆JobDetail錛氫換鍔$粏鑺傦紝Quartz鎵цJob鏃訛紝闇瑕佹柊寤轟釜Job瀹炰緥錛屼絾鏄笉鑳界洿鎺ユ搷浣淛ob綾伙紝鎵浠ラ氳繃JobDetail鏉ヨ幏鍙朖ob鐨勫悕縐般佹弿榪頒俊鎭?/p>

銆銆Trigger瑙﹀彂鍣細鎵ц浠誨姟鐨勮鍒?姣斿姣忓ぉ錛屾瘡灝忔椂絳夈?/p>

銆銆涓鑸儏鍐典嬌鐢⊿impleTrigger錛屽拰CronTrigger錛岃繖涓Е鍙戝櫒瀹炵幇浜員rigger鎺ュ彛銆?/p>

銆銆瀵逛簬澶嶆潅鐨勬椂闂磋〃杈懼紡鏉ヨ錛屾瘮濡傛瘡涓湀15鏃ヤ笂鍗堝嚑鐐瑰嚑鍒嗭紝浣跨敤CronTrigger

銆銆瀵逛簬綆鍗曠殑鏃墮棿鏉ヨ錛屾瘮濡傛瘡澶╂墽琛屽嚑嬈★紝浣跨敤SimpleTrigger

銆銆scheduler浠誨姟璋冨害錛氭槸鏈鏍稿績鐨勬蹇碉紝闇瑕佹妸JobDetail鍜孴rigger娉ㄥ唽鍒皊cheduler涓紝鎵嶅彲浠ユ墽琛屻?/p>

銆銆娉ㄦ剰錛?/p>

銆銆涓嶅悓鐨勭増鏈殑jar鍖咃紝鍏蜂綋鐨勬搷浣滀笉澶浉鍚岋紝浣嗘槸tbw鎬濊礬鏄浉鍚岀殑;姣斿1.8.6jar鍖呬腑錛孞obDetail鏄釜綾伙紝鐩存帴閫氳繃鏋勯犳柟娉曚笌Job綾誨叧鑱斻係impleTrigger鍜?CornTrigger鏄被;鍦?.0.2jar鍖呬腑錛孞obDetail鏄釜鎺ュ彛錛孲impleTrigger鍜孋ornTrigger鏄帴鍙?/p>

銆銆涓嶅悓鐗堟湰嫻嬭瘯錛?/p>

銆銆1.8.6jar鍖咃細
銆銆package com.test;

銆銆import java.util.Date;

銆銆import org.quartz.Job;

銆銆import org.quartz.JobExecutionContext;

銆銆import org.quartz.JobExecutionException;

銆銆/**

銆銆* 闇瑕佹墽琛岀殑浠誨姟

銆銆* @author lhy

銆銆*

銆銆*/

銆銆public class MyJob implements Job {

銆銆@Override

銆銆//鎶婅鎵ц鐨勬搷浣滐紝鍐欏湪execute鏂規硶涓?/p>

銆銆public void execute(JobExecutionContext arg0) throws JobExecutionException {

銆銆System.out.println("嫻嬭瘯Quartz"+new Date());

銆銆}

銆銆}
    
     浣跨敤SimpleTrigger瑙﹀彂鍣?br />銆銆package com.test;

銆銆import java.util.Date;

銆銆import org.quartz.JobDetail;

銆銆import org.quartz.Scheduler;

銆銆import org.quartz.SchedulerException;

銆銆import org.quartz.SchedulerFactory;

銆銆import org.quartz.SimpleTrigger;

銆銆import org.quartz.impl.StdSchedulerFactory;

銆銆/**

銆銆* 璋冪敤浠誨姟鐨勭被

銆銆* @author lhy

銆銆*

銆銆*/

銆銆public class SchedulerTest {

銆銆public static void main(String[] args) {

銆銆//閫氳繃schedulerFactory鑾峰彇涓涓皟搴﹀櫒

銆銆SchedulerFactory schedulerfactory=new StdSchedulerFactory();

銆銆Scheduler scheduler=null;

銆銆try{

銆銆// 閫氳繃schedulerFactory鑾峰彇涓涓皟搴﹀櫒

銆銆scheduler=schedulerfactory.getScheduler();

銆銆// 鍒涘緩jobDetail瀹炰緥錛岀粦瀹欽ob瀹炵幇綾?/p>

銆銆// 鎸囨槑job鐨勫悕縐幫紝鎵鍦ㄧ粍鐨勫悕縐幫紝浠ュ強緇戝畾job綾?/p>

銆銆JobDetail jobDetail=new JobDetail("job1", "jgroup1", MyJob.class);

銆銆// 瀹氫箟璋冨害瑙﹀彂瑙勫垯錛屾瘮濡傛瘡1縐掕繍琛屼竴嬈★紝鍏辮繍琛?嬈?/p>

銆銆SimpleTrigger simpleTrigger=new SimpleTrigger("simpleTrigger","triggerGroup");

銆銆// 椹笂鍚姩

銆銆simpleTrigger.setStartTime(new Date());

銆銆// 闂撮殧鏃墮棿

銆銆simpleTrigger.setRepeatInterval(1000);

銆銆// 榪愯嬈℃暟

銆銆simpleTrigger.setRepeatCount(8);

銆銆// 鎶婁綔涓氬拰瑙﹀彂鍣ㄦ敞鍐屽埌浠誨姟璋冨害涓?/p>

銆銆scheduler.scheduleJob(jobDetail, simpleTrigger);

銆銆// 鍚姩璋冨害

銆銆scheduler.start();

銆銆}catch(SchedulerException e){

銆銆e.printStackTrace();

銆銆}

銆銆}

銆銆}

     鑻ヤ嬌鐢–ornTrigger瑙﹀彂鍣細

銆銆[html]

銆銆package com.test;

銆銆import java.util.Date;

銆銆import org.quartz.CronTrigger;

銆銆import org.quartz.JobDetail;

銆銆import org.quartz.Scheduler;

銆銆import org.quartz.SchedulerException;

銆銆import org.quartz.SchedulerFactory;

銆銆import org.quartz.SimpleTrigger;

銆銆import org.quartz.impl.StdSchedulerFactory;

銆銆/**

銆銆* 璋冪敤浠誨姟鐨勭被

銆銆* @author lhy

銆銆*

銆銆*/

銆銆public class CronTriggerTest {

銆銆public static void main(String[] args) {

銆銆//閫氳繃schedulerFactory鑾峰彇涓涓皟搴﹀櫒

銆銆SchedulerFactory schedulerfactory=new StdSchedulerFactory();

銆銆Scheduler scheduler=null;

銆銆try{

銆銆// 閫氳繃schedulerFactory鑾峰彇涓涓皟搴﹀櫒

銆銆scheduler=schedulerfactory.getScheduler();

銆銆// 鍒涘緩jobDetail瀹炰緥錛岀粦瀹欽ob瀹炵幇綾?/p>

銆銆// 鎸囨槑job鐨勫悕縐幫紝鎵鍦ㄧ粍鐨勫悕縐幫紝浠ュ強緇戝畾job綾?/p>

銆銆JobDetail jobDetail=new JobDetail("job1", "jgroup1", MyJob.class);

銆銆// 瀹氫箟璋冨害瑙﹀彂瑙勫垯錛屾瘡澶╀笂鍗?0錛?5鎵ц

銆銆CronTrigger cornTrigger=new CronTrigger("cronTrigger","triggerGroup");

銆銆// 鎵ц瑙勫垯琛ㄨ揪寮?/p>

銆銆cornTrigger.setCronExpression("0 15 10 * * ? *");

銆銆// 鎶婁綔涓氬拰瑙﹀彂鍣ㄦ敞鍐屽埌浠誨姟璋冨害涓?/p>

銆銆scheduler.scheduleJob(jobDetail, cornTrigger);

銆銆// 鍚姩璋冨害

銆銆scheduler.start();

銆銆}catch(Exception e){

銆銆e.printStackTrace();

銆銆}

銆銆}

銆銆}

銆銆瀵逛簬2.0.2jar鍖呭涓嬶細

銆銆鍏朵腑鐨刯ob綾諱笉鍙橈紝涓昏鏄皟搴︾被濡備笅錛?/p>

銆銆package com.test;

銆銆import java.util.Date;

銆銆import org.quartz.CronScheduleBuilder;

銆銆import org.quartz.JobBuilder;

銆銆import org.quartz.JobDetail;

銆銆import org.quartz.Scheduler;

銆銆import org.quartz.SchedulerException;

銆銆import org.quartz.SchedulerFactory;

銆銆import org.quartz.SimpleScheduleBuilder;

銆銆import org.quartz.Trigger;

銆銆import org.quartz.TriggerBuilder;

銆銆import org.quartz.impl.StdSchedulerFactory;

銆銆/**

銆銆* 璋冪敤浠誨姟鐨勭被

銆銆* @author lhy

銆銆*

銆銆*/

銆銆public class SchedulerTest {

銆銆public static void main(String[] args) {

銆銆//閫氳繃schedulerFactory鑾峰彇涓涓皟搴﹀櫒

銆銆SchedulerFactory schedulerfactory=new StdSchedulerFactory();

銆銆Scheduler scheduler=null;

銆銆try{

銆銆// 閫氳繃schedulerFactory鑾峰彇涓涓皟搴﹀櫒

銆銆scheduler=schedulerfactory.getScheduler();

銆銆// 鍒涘緩jobDetail瀹炰緥錛岀粦瀹欽ob瀹炵幇綾?/p>

銆銆// 鎸囨槑job鐨勫悕縐幫紝鎵鍦ㄧ粍鐨勫悕縐幫紝浠ュ強緇戝畾job綾?/p>

銆銆JobDetail job=JobBuilder.newJob(MyJob.class).withIdentity("job1", "jgroup1").build();

銆銆// 瀹氫箟璋冨害瑙﹀彂瑙勫垯

銆銆// 浣跨敤simpleTrigger瑙勫垯

銆銆// Trigger trigger=TriggerBuilder.newTrigger().withIdentity("simpleTrigger", "triggerGroup")

銆銆// .withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(1).withRepeatCount(8))

銆銆// .startNow().build();

銆銆// 浣跨敤cornTrigger瑙勫垯 姣忓ぉ10鐐?2鍒?/p>

銆銆Trigger trigger=TriggerBuilder.newTrigger().withIdentity("simpleTrigger", "triggerGroup")

銆銆.withSchedule(CronScheduleBuilder.cronSchedule("0 42 10 * * ? *"))

銆銆.startNow().build();

銆銆// 鎶婁綔涓氬拰瑙﹀彂鍣ㄦ敞鍐屽埌浠誨姟璋冨害涓?/p>

銆銆scheduler.scheduleJob(job, trigger);

銆銆// 鍚姩璋冨害

銆銆scheduler.start();

銆銆}catch(Exception e){

銆銆e.printStackTrace();

銆銆}

銆銆}

銆銆}

銆銆涓婅堪demo涓嬭澆錛?.8鐗堟湰demo涓嬭澆

銆銆2.0鐗堟湰demo涓嬭澆

銆銆瀵逛簬CornExpress璁茶В濡備笅錛?/p>

銆銆瀛楁 鍏佽鍊?鍏佽鐨勭壒孌婂瓧絎?/p>

銆銆縐?0-59 , - * /

銆銆鍒?0-59 , - * /

銆銆灝忔椂 0-23 , - * /

銆銆鏃ユ湡 1-31 , - * ? / L W C

銆銆鏈堜喚 1-12 鎴栬?JAN-DEC , - * /

銆銆鏄熸湡 1-7 鎴栬?SUN-SAT , - * ? / L C #

銆銆騫?鍙? 鐣欑┖, 1970-2099 , - * /

銆銆琛ㄨ揪寮?鎰忎箟

銆銆"0 0 12 * * ?" 姣忓ぉ涓崍12鐐硅Е鍙?/p>

銆銆"0 15 10 ? * *" 姣忓ぉ涓婂崍10:15瑙﹀彂

銆銆"0 15 10 * * ?" 姣忓ぉ涓婂崍10:15瑙﹀彂

銆銆"0 15 10 * * ? *" 姣忓ぉ涓婂崍10:15瑙﹀彂

銆銆"0 15 10 * * ? 2005" 2005騫寸殑姣忓ぉ涓婂崍10:15瑙﹀彂

銆銆"0 * 14 * * ?" 鍦ㄦ瘡澶╀笅鍗?鐐瑰埌涓嬪崍2:59鏈熼棿鐨勬瘡1鍒嗛挓瑙﹀彂

銆銆"0 0/5 14 * * ?" 鍦ㄦ瘡澶╀笅鍗?鐐瑰埌涓嬪崍2:55鏈熼棿鐨勬瘡5鍒嗛挓瑙﹀彂

銆銆"0 0/5 14,18 * * ?" 鍦ㄦ瘡澶╀笅鍗?鐐瑰埌2:55鏈熼棿鍜屼笅鍗?鐐瑰埌6:55鏈熼棿鐨勬瘡5鍒嗛挓瑙﹀彂

銆銆"0 0-5 14 * * ?" 鍦ㄦ瘡澶╀笅鍗?鐐瑰埌涓嬪崍2:05鏈熼棿鐨勬瘡1鍒嗛挓瑙﹀彂

銆銆"0 10,44 14 ? 3 WED" 姣忓勾涓夋湀鐨勬槦鏈熶笁鐨勪笅鍗?:10鍜?:44瑙﹀彂

銆銆"0 15 10 ? * MON-FRI" 鍛ㄤ竴鑷沖懆浜旂殑涓婂崍10:15瑙﹀彂

銆銆"0 15 10 15 * ?" 姣忔湀15鏃ヤ笂鍗?0:15瑙﹀彂

銆銆"0 15 10 L * ?" 姣忔湀鏈鍚庝竴鏃ョ殑涓婂崍10:15瑙﹀彂

銆銆"0 15 10 ? * 6L" 姣忔湀鐨勬渶鍚庝竴涓槦鏈熶簲涓婂崍10:15瑙﹀彂

銆銆"0 15 10 ? * 6L 2002-2005" 2002騫磋嚦2005騫寸殑姣忔湀鐨勬渶鍚庝竴涓槦鏈熶簲涓婂崍10:15瑙﹀彂

銆銆"0 15 10 ? * 6#3" 姣忔湀鐨勭涓変釜鏄熸湡浜斾笂鍗?0:15瑙﹀彂

銆銆鐗規畩瀛楃 鎰忎箟

銆銆* 琛ㄧず鎵鏈夊?

銆銆? 琛ㄧず鏈鏄庣殑鍊鹼紝鍗充笉鍏沖績瀹冧負浣曞?

銆銆- 琛ㄧず涓涓寚瀹氱殑鑼冨洿;

銆銆, 琛ㄧず闄勫姞涓涓彲鑳藉?

銆銆/ 絎﹀彿鍓嶈〃紺哄紑濮嬫椂闂達紝絎﹀彿鍚庤〃紺烘瘡嬈¢掑鐨勫?

銆銆L("last") ("last") "L" 鐢ㄥ湪day-of-month瀛楁鎰忔濇槸 "榪欎釜鏈堟渶鍚庝竴澶?;鐢ㄥ湪 day-of-week瀛楁, 瀹冪畝鍗曟剰鎬濇槸 "7" or "SAT"銆?濡傛灉鍦╠ay-of-week瀛楁閲屽拰鏁板瓧鑱斿悎浣跨敤錛屽畠鐨勬剰鎬濆氨鏄?"榪欎釜鏈堢殑鏈鍚庝竴涓槦鏈熷嚑" – 渚嬪錛?"6L" means "榪欎釜鏈堢殑鏈鍚庝竴涓槦鏈熶簲". 褰撴垜浠敤“L”鏃訛紝涓嶆寚鏄庝竴涓垪琛ㄥ兼垨鑰呰寖鍥存槸寰堥噸瑕佺殑錛屼笉鐒剁殑璇濓紝鎴戜滑浼氬緱鍒頒竴浜涙剰鎯充笉鍒扮殑緇撴灉銆?/p>

銆銆W("weekday") 鍙兘鐢ㄥ湪day-of-month瀛楁銆傜敤鏉ユ弿鍙欐渶鎺ヨ繎鎸囧畾澶╃殑宸ヤ綔鏃?鍛ㄤ竴鍒板懆浜?銆備緥濡傦細鍦╠ay-of-month瀛楁鐢?#8220;15W”鎸?#8220;鏈鎺ヨ繎榪欎釜鏈堢15澶╃殑宸ヤ綔鏃?#8221;錛屽嵆濡傛灉榪欎釜鏈堢15澶╂槸鍛ㄥ叚錛岄偅涔堣Е鍙戝櫒灝嗕細鍦ㄨ繖涓湀絎?4澶╁嵆鍛ㄤ簲瑙﹀彂;濡傛灉榪欎釜鏈堢15澶╂槸鍛ㄦ棩錛岄偅涔堣Е鍙戝櫒灝嗕細鍦ㄨ繖涓湀絎?16澶╁嵆鍛ㄤ竴瑙﹀彂;濡傛灉榪欎釜鏈堢15澶╂槸鍛ㄤ簩錛岄偅涔堝氨鍦?strong>tbw瑙﹀彂鍣ㄨ繖澶╄Е鍙戙傛敞鎰忎竴鐐癸細榪欎釜鐢ㄦ硶鍙細鍦ㄥ綋鍓嶆湀璁$畻鍊鹼紝涓嶄細瓚婅繃褰撳墠鏈堛?#8220;W”瀛楃浠呰兘鍦╠ay-of-month鎸囨槑涓澶╋紝涓嶈兘鏄竴涓寖鍥存垨鍒楄〃銆備篃鍙互鐢?#8220;LW”鏉ユ寚瀹氳繖涓湀鐨勬渶鍚庝竴涓伐浣滄棩銆?/p>

銆銆# 鍙兘鐢ㄥ湪day-of-week瀛楁銆傜敤鏉ユ寚瀹氳繖涓湀鐨勭鍑犱釜鍛ㄥ嚑銆備緥錛氬湪day-of-week瀛楁鐢?6#3"鎸囪繖涓湀絎?涓懆浜?6鎸囧懆浜旓紝3鎸囩3涓?銆傚鏋滄寚瀹氱殑鏃ユ湡涓嶅瓨鍦紝瑙﹀彂鍣ㄥ氨涓嶄細瑙﹀彂銆?/p>

銆銆C 鎸囧拰calendar鑱旂郴鍚庤綆楄繃鐨勫箋備緥錛氬湪day-of-month 瀛楁鐢?#8220;5C”鎸囧湪榪欎釜鏈堢5澶╂垨涔嬪悗鍖呮嫭calendar鐨勭涓澶?鍦╠ay-of-week瀛楁鐢?#8220;1C”鎸囧湪榪欏懆鏃ユ垨涔嬪悗鍖呮嫭calendar鐨勭涓澶?/p>

]]>
閫氳繃JAVA鑾峰彇浼橀叿銆佸湡璞嗐侀叿6銆?闂存埧絳夎棰?/title><link>http://www.tkk7.com/wshao/archive/2013/12/31/408268.html</link><dc:creator>鍗堝悗鏄熸湡鍗?/dc:creator><author>鍗堝悗鏄熸湡鍗?/author><pubDate>Tue, 31 Dec 2013 05:59:00 GMT</pubDate><guid>http://www.tkk7.com/wshao/archive/2013/12/31/408268.html</guid><wfw:comment>http://www.tkk7.com/wshao/comments/408268.html</wfw:comment><comments>http://www.tkk7.com/wshao/archive/2013/12/31/408268.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/wshao/comments/commentRss/408268.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/wshao/services/trackbacks/408268.html</trackback:ping><description><![CDATA[     鎽樿: 閫氳繃JAVA鑾峰彇浼橀叿銆佸湡璞嗐侀叿6銆?闂存埧銆?6瑙嗛錛岀幇鍦ㄥ緢澶氱ぞ浼氱綉绔欓兘鏈夎繖涓姛鑳斤紝鐢ㄦ埛杈撳叆浼橀叿銆佸湡璞嗐侀叿6銆?闂存埧銆?6瑙嗛鍦板潃鍚庯紝鑳芥壘鍒板搴旂殑瑙嗛鍙婅棰戠殑緙╃暐鍥撅紝鏈変簺紺懼尯緗戠珯榪樿兘鑾峰彇鍒拌棰戠殑鏃墮暱銆?姣斿錛氭柊嫻井鍗氬氨鏈夎繖涓姛鑳斤紝褰撶敤鎴瘋緭鍏ヤ紭閰楓佸湡璞嗐侀叿6銆?闂存埧銆?6瑙嗛緗戝潃鍚庯紝灝辮兘鑾峰彇鍒扮浉搴旂殑瑙嗛鍦板潃鍙婅棰戠殑緙╃暐鍥俱備唬鐮佸涓嬶細 import org.jsoup.Jsoup;imp...  <a href='http://www.tkk7.com/wshao/archive/2013/12/31/408268.html'>闃呰鍏ㄦ枃</a><img src ="http://www.tkk7.com/wshao/aggbug/408268.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wshao/" target="_blank">鍗堝悗鏄熸湡鍗?/a> 2013-12-31 13:59 <a href="http://www.tkk7.com/wshao/archive/2013/12/31/408268.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Ehcache璇︾粏瑙hhttp://www.tkk7.com/wshao/archive/2013/12/31/408265.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 05:56:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408265.htmlhttp://www.tkk7.com/wshao/comments/408265.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408265.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408265.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408265.html闃呰鍏ㄦ枃

]]>
Hibernate ehcache閰嶇疆浜岀駭緙撳瓨http://www.tkk7.com/wshao/archive/2013/12/31/408263.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 05:54:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408263.htmlhttp://www.tkk7.com/wshao/comments/408263.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408263.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408263.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408263.html闃呰鍏ㄦ枃

]]>
Spring閭歡鏈嶅姟涔嬮檮浠訛細Maven + Spring SMTP Mail With Attachmenthttp://www.tkk7.com/wshao/archive/2013/12/31/408261.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 05:52:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408261.htmlhttp://www.tkk7.com/wshao/comments/408261.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408261.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408261.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408261.html闃呰鍏ㄦ枃

]]>
Spring閭歡鏈嶅姟涔婬tml錛歁aven + Spring SMTP Mail With Htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408262.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 05:52:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408262.htmlhttp://www.tkk7.com/wshao/comments/408262.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408262.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408262.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408262.html闃呰鍏ㄦ枃

]]>
Spring閭歡鏈嶅姟錛歁aven + Spring SMTP Mailhttp://www.tkk7.com/wshao/archive/2013/12/31/408260.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 05:50:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408260.htmlhttp://www.tkk7.com/wshao/comments/408260.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408260.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408260.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408260.html闃呰鍏ㄦ枃

]]>
JFreeChart 鐢熸垚 鎶樼嚎鍥撅紙Struts2 + Maven3 + JFreeChart錛?/title><link>http://www.tkk7.com/wshao/archive/2013/12/31/408257.html</link><dc:creator>鍗堝悗鏄熸湡鍗?/dc:creator><author>鍗堝悗鏄熸湡鍗?/author><pubDate>Tue, 31 Dec 2013 05:48:00 GMT</pubDate><guid>http://www.tkk7.com/wshao/archive/2013/12/31/408257.html</guid><wfw:comment>http://www.tkk7.com/wshao/comments/408257.html</wfw:comment><comments>http://www.tkk7.com/wshao/archive/2013/12/31/408257.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/wshao/comments/commentRss/408257.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/wshao/services/trackbacks/408257.html</trackback:ping><description><![CDATA[     鎽樿: 鎺ヤ笂涓綃囬殢絎?nbsp;JFreeChart 鐢熸垚 鏌辯姸鍥?錛岀幆澧冨強鍏墮厤緗笉鍙橈紝鍙槸灝嗙敓鎴愭煴鐘跺浘鐨勬牳蹇冪被 CylinderAction 鏇挎崲鎴?CurveAction錛岃 CurveAction鏉ヨ礋璐f姌綰垮浘鐨勭敓鎴愶紝鐪嬩笅浠g爜錛?Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlig...  <a href='http://www.tkk7.com/wshao/archive/2013/12/31/408257.html'>闃呰鍏ㄦ枃</a><img src ="http://www.tkk7.com/wshao/aggbug/408257.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wshao/" target="_blank">鍗堝悗鏄熸湡鍗?/a> 2013-12-31 13:48 <a href="http://www.tkk7.com/wshao/archive/2013/12/31/408257.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>JFreeChart 鐢熸垚 楗肩姸鍥撅紙Struts2 + Maven3 + JFreeChart錛?/title><link>http://www.tkk7.com/wshao/archive/2013/12/31/408256.html</link><dc:creator>鍗堝悗鏄熸湡鍗?/dc:creator><author>鍗堝悗鏄熸湡鍗?/author><pubDate>Tue, 31 Dec 2013 05:47:00 GMT</pubDate><guid>http://www.tkk7.com/wshao/archive/2013/12/31/408256.html</guid><wfw:comment>http://www.tkk7.com/wshao/comments/408256.html</wfw:comment><comments>http://www.tkk7.com/wshao/archive/2013/12/31/408256.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/wshao/comments/commentRss/408256.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/wshao/services/trackbacks/408256.html</trackback:ping><description><![CDATA[<span style="font-family: Georgia; font-size: 10pt">鎺ヤ笂涓綃囬殢絎?nbsp;<a style="color: #008080" href="http://www.tkk7.com/fancydeepin/archive/2012/08/07/java_jfreechart_BarChart3D.html" target="_blank">JFreeChart 鐢熸垚 鏌辯姸鍥?/a> 錛岀幆澧冨強鍏墮厤緗笉鍙橈紝鍙槸灝嗙敓鎴愭煴鐘跺浘鐨勬牳蹇冪被 CylinderAction 鏇挎崲鎴?PieAction錛岃 PieAction 鏉ヨ礋璐iゼ鐘跺浘鐨勭敓鎴愶紝鐪嬩笅浠g爜錛?br /><br /><br /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /><span style="color: #000000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">package</span><span style="color: #000000"> com.fancy.action;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.awt.Color;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.jfree.chart.ChartFactory;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.jfree.chart.JFreeChart;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.jfree.chart.servlet.ServletUtilities;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.jfree.data.general.DefaultPieDataset;<br /><img id="Codehighlighter1_221_393_Open_Image" onclick="this.style.display='none'; Codehighlighter1_221_393_Open_Text.style.display='none'; Codehighlighter1_221_393_Closed_Image.style.display='inline'; Codehighlighter1_221_393_Closed_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_221_393_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_221_393_Closed_Text.style.display='none'; Codehighlighter1_221_393_Open_Image.style.display='inline'; Codehighlighter1_221_393_Open_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span id="Codehighlighter1_221_393_Open_Text"><span style="color: #008000">/**</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * -----------------------------------------<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * @鎻忚堪  楗肩姸鍥?br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * @浣滆?nbsp; fancy<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * @閭  fancydeepin@yeah.net<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * @鏃ユ湡  2012-8-7 <p><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * -----------------------------------------<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" /> </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /><img id="Codehighlighter1_436_1203_Open_Image" onclick="this.style.display='none'; Codehighlighter1_436_1203_Open_Text.style.display='none'; Codehighlighter1_436_1203_Closed_Image.style.display='inline'; Codehighlighter1_436_1203_Closed_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_436_1203_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_436_1203_Closed_Text.style.display='none'; Codehighlighter1_436_1203_Open_Image.style.display='inline'; Codehighlighter1_436_1203_Open_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> PieAction </span><span style="color: #0000ff">extends</span><span style="color: #000000"> BaseAction</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_436_1203_Closed_Text"></span><span id="Codehighlighter1_436_1203_Open_Text"><span style="color: #000000">{<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> </span><span style="color: #0000ff">final</span><span style="color: #000000"> </span><span style="color: #0000ff">long</span><span style="color: #000000"> serialVersionUID </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">1L</span><span style="color: #000000">;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> String fileName;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />    <br /><img id="Codehighlighter1_558_1145_Open_Image" onclick="this.style.display='none'; Codehighlighter1_558_1145_Open_Text.style.display='none'; Codehighlighter1_558_1145_Closed_Image.style.display='inline'; Codehighlighter1_558_1145_Closed_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_558_1145_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_558_1145_Closed_Text.style.display='none'; Codehighlighter1_558_1145_Open_Image.style.display='inline'; Codehighlighter1_558_1145_Open_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="color: #0000ff">public</span><span style="color: #000000"> String execute() </span><span style="color: #0000ff">throws</span><span style="color: #000000"> Exception</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_558_1145_Closed_Text"></span><span id="Codehighlighter1_558_1145_Open_Text"><span style="color: #000000">{<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        <br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000">鍒涘緩Dataset瀵硅薄</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        DefaultPieDataset dataset </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> DefaultPieDataset();<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000">妯℃嫙鏁版嵁</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-1鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">50</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-2鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">150</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-3鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">80</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-4鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">140</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-5鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">180</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-6鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">130</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-7鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">100</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000">鍒涘緩3D楗肩姸鍥?/span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        JFreeChart chart </span><span style="color: #000000">=</span><span style="color: #000000"> ChartFactory.createPieChart3D(</span><span style="color: #000000">"</span><span style="color: #000000">2011騫碅浜у搧閿鍞噺</span><span style="color: #000000">"</span><span style="color: #000000">, dataset, </span><span style="color: #0000ff">true</span><span style="color: #000000">, </span><span style="color: #0000ff">false</span><span style="color: #000000">, </span><span style="color: #0000ff">false</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000">璁劇疆鑳屾櫙棰滆壊</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        chart.setBackgroundPaint(Color.WHITE);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000">淇濆瓨鍥捐〃</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        fileName </span><span style="color: #000000">=</span><span style="color: #000000"> ServletUtilities.saveChartAsPNG(chart, </span><span style="color: #000000">500</span><span style="color: #000000">, </span><span style="color: #000000">300</span><span style="color: #000000">, </span><span style="color: #0000ff">null</span><span style="color: #000000">, getHttpSession());<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">pie</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" />    }</span></span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />    <br /><img id="Codehighlighter1_1178_1200_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1178_1200_Open_Text.style.display='none'; Codehighlighter1_1178_1200_Closed_Image.style.display='inline'; Codehighlighter1_1178_1200_Closed_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1178_1200_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1178_1200_Closed_Text.style.display='none'; Codehighlighter1_1178_1200_Open_Image.style.display='inline'; Codehighlighter1_1178_1200_Open_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="color: #0000ff">public</span><span style="color: #000000"> String getFileName() </span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1178_1200_Closed_Text"></span><span id="Codehighlighter1_1178_1200_Open_Text"><span style="color: #000000">{<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> fileName;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" />    }</span></span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" />}</span></span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span></div><br /><br />灝?cylinder.jsp 鎷瘋礉涓浠藉悕瀛楁敼鎴?pie.jsp錛屽叾浣欎笉鍙橈紝璁塊棶錛?a style="color: #993300" href="http://localhost:8080/jfreechart-demo/pie.html" target="_blank">http://localhost:8080/jfreechart-demo/pie.html</a> 鐨勭粨鏋滃鍥劇ず錛?br /><br /><img border="0" alt="" src="http://www.tkk7.com/images/blogjava_net/fancydeepin/pie1.jpg" width="523" longdesc="" height="327" /><br /><br />浠庝笂鍥懼彲浠ョ湅鍑篈浜у搧鍦ㄦ瘡涓尯閿鍞殑澶ф浠介錛屼絾鏄粯璁ゅ茍娌℃湁緇欐樉紺烘墍鍗犵殑鐧懼垎姣旓紝涓嬮潰閫氳繃娣誨姞浠g爜鏉ヤ嬌寰楁墍鍗犵櫨鍒嗘瘮鑳藉鏄劇ず鍑烘潵錛?br /><br /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /><span style="color: #000000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">package</span><span style="color: #000000"> com.fancy.action;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.awt.Color;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.text.DecimalFormat;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.text.NumberFormat;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.jfree.chart.ChartFactory;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.jfree.chart.JFreeChart;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.jfree.chart.labels.StandardPieSectionLabelGenerator;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.jfree.chart.plot.PiePlot;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.jfree.chart.servlet.ServletUtilities;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.jfree.data.general.DefaultPieDataset;<br /><img id="Codehighlighter1_385_557_Open_Image" onclick="this.style.display='none'; Codehighlighter1_385_557_Open_Text.style.display='none'; Codehighlighter1_385_557_Closed_Image.style.display='inline'; Codehighlighter1_385_557_Closed_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_385_557_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_385_557_Closed_Text.style.display='none'; Codehighlighter1_385_557_Open_Image.style.display='inline'; Codehighlighter1_385_557_Open_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span id="Codehighlighter1_385_557_Open_Text"><span style="color: #008000">/**</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * -----------------------------------------<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * @鎻忚堪  楗肩姸鍥?br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * @浣滆?nbsp; fancy<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * @閭  fancydeepin@yeah.net<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * @鏃ユ湡  2012-8-7 <p><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /> * -----------------------------------------<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" /> </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /><img id="Codehighlighter1_600_1620_Open_Image" onclick="this.style.display='none'; Codehighlighter1_600_1620_Open_Text.style.display='none'; Codehighlighter1_600_1620_Closed_Image.style.display='inline'; Codehighlighter1_600_1620_Closed_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_600_1620_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_600_1620_Closed_Text.style.display='none'; Codehighlighter1_600_1620_Open_Image.style.display='inline'; Codehighlighter1_600_1620_Open_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> PieAction </span><span style="color: #0000ff">extends</span><span style="color: #000000"> BaseAction</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_600_1620_Closed_Text"></span><span id="Codehighlighter1_600_1620_Open_Text"><span style="color: #000000">{<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> </span><span style="color: #0000ff">final</span><span style="color: #000000"> </span><span style="color: #0000ff">long</span><span style="color: #000000"> serialVersionUID </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">1L</span><span style="color: #000000">;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> String fileName;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />    <br /><img id="Codehighlighter1_722_1562_Open_Image" onclick="this.style.display='none'; Codehighlighter1_722_1562_Open_Text.style.display='none'; Codehighlighter1_722_1562_Closed_Image.style.display='inline'; Codehighlighter1_722_1562_Closed_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_722_1562_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_722_1562_Closed_Text.style.display='none'; Codehighlighter1_722_1562_Open_Image.style.display='inline'; Codehighlighter1_722_1562_Open_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="color: #0000ff">public</span><span style="color: #000000"> String execute() </span><span style="color: #0000ff">throws</span><span style="color: #000000"> Exception</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_722_1562_Closed_Text"></span><span id="Codehighlighter1_722_1562_Open_Text"><span style="color: #000000">{<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        <br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000">鍒涘緩Dataset瀵硅薄</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        DefaultPieDataset dataset </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> DefaultPieDataset();<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000">妯℃嫙鏁版嵁</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-1鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">50</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-2鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">150</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-3鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">80</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-4鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">140</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-5鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">180</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-6鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">130</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        dataset.setValue(</span><span style="color: #000000">"</span><span style="color: #000000">E-7鍖?/span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">100</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000">鍒涘緩3D楗肩姸鍥?/span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        JFreeChart chart </span><span style="color: #000000">=</span><span style="color: #000000"> ChartFactory.createPieChart3D(</span><span style="color: #000000">"</span><span style="color: #000000">2011騫碅A浜у搧閿鍞噺</span><span style="color: #000000">"</span><span style="color: #000000">, dataset, </span><span style="color: #0000ff">true</span><span style="color: #000000">, </span><span style="color: #0000ff">false</span><span style="color: #000000">, </span><span style="color: #0000ff">false</span><span style="color: #000000">);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000">璁劇疆鑳屾櫙棰滆壊</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        chart.setBackgroundPaint(Color.WHITE);<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        <br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        PiePlot plot </span><span style="color: #000000">=</span><span style="color: #000000"> (PiePlot)chart.getPlot();<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000"> 鍥劇墖涓樉紺虹櫨鍒嗘瘮錛氳嚜瀹氫箟鏂瑰紡錛寋0} 琛ㄧず閫夐」錛?nbsp;{1} 琛ㄧず鏁板鹼紝{2} 琛ㄧず鎵鍗犳瘮渚?nbsp;錛屽皬鏁扮偣鍚庝袱浣?nbsp;</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        plot.setLabelGenerator(</span><span style="color: #0000ff">new</span><span style="color: #000000"> StandardPieSectionLabelGenerator(</span><span style="color: #000000">"</span><span style="color: #000000">{0}={1}({2})</span><span style="color: #000000">"</span><span style="color: #000000">, NumberFormat.getNumberInstance(),</span><span style="color: #0000ff">new</span><span style="color: #000000"> DecimalFormat(</span><span style="color: #000000">"</span><span style="color: #000000">0.00%</span><span style="color: #000000">"</span><span style="color: #000000">)));<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        <br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #008000">//</span><span style="color: #008000">淇濆瓨鍥捐〃</span><span style="color: #008000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /></span><span style="color: #000000">        fileName </span><span style="color: #000000">=</span><span style="color: #000000"> ServletUtilities.saveChartAsPNG(chart, </span><span style="color: #000000">500</span><span style="color: #000000">, </span><span style="color: #000000">300</span><span style="color: #000000">, </span><span style="color: #0000ff">null</span><span style="color: #000000">, getHttpSession());<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">pie</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" />    }</span></span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />    <br /><img id="Codehighlighter1_1595_1617_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1595_1617_Open_Text.style.display='none'; Codehighlighter1_1595_1617_Closed_Image.style.display='inline'; Codehighlighter1_1595_1617_Closed_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1595_1617_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1595_1617_Closed_Text.style.display='none'; Codehighlighter1_1595_1617_Open_Image.style.display='inline'; Codehighlighter1_1595_1617_Open_Text.style.display='inline';" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="color: #0000ff">public</span><span style="color: #000000"> String getFileName() </span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1595_1617_Closed_Text"></span><span id="Codehighlighter1_1595_1617_Open_Text"><span style="color: #000000">{<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> fileName;<br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" />    }</span></span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/InBlock.gif" /><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" />}</span></span><span style="color: #000000"><br /><img alt="" align="top" src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" /></span></div><br /><br />OK錛屽啀嬈¤闂殑緇撴灉濡傚浘紺猴細<br /><br /><img border="0" alt="" src="http://www.tkk7.com/images/blogjava_net/fancydeepin/pie2.jpg" width="529" longdesc="" height="332" /><br /><br /></span><br /><br /><span style="font-family: Georgia; font-size: 10pt"><br /><span style="font-family: Georgia; color: #008000; font-size: 10pt">   [ 杞澆鍑哄錛?a href="http://www.tkk7.com/fancydeepin" target="_blank"><font color="#1d58d1">http://www.tkk7.com/fancydeepin</font></a> ]</span></span><font size="2"> </font><br /><img src ="http://www.tkk7.com/wshao/aggbug/408256.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wshao/" target="_blank">鍗堝悗鏄熸湡鍗?/a> 2013-12-31 13:47 <a href="http://www.tkk7.com/wshao/archive/2013/12/31/408256.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>JFreeChart 鐢熸垚 鏌辯姸鍥撅紙Struts2 + Maven3 + JFreeChart錛?/title><link>http://www.tkk7.com/wshao/archive/2013/12/31/408255.html</link><dc:creator>鍗堝悗鏄熸湡鍗?/dc:creator><author>鍗堝悗鏄熸湡鍗?/author><pubDate>Tue, 31 Dec 2013 05:46:00 GMT</pubDate><guid>http://www.tkk7.com/wshao/archive/2013/12/31/408255.html</guid><wfw:comment>http://www.tkk7.com/wshao/comments/408255.html</wfw:comment><comments>http://www.tkk7.com/wshao/archive/2013/12/31/408255.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/wshao/comments/commentRss/408255.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/wshao/services/trackbacks/408255.html</trackback:ping><description><![CDATA[     鎽樿: 鍑嗗鐜錛?Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->eclipse   3.6maven   3.0.4struts     2.1.8JFreeCha...  <a href='http://www.tkk7.com/wshao/archive/2013/12/31/408255.html'>闃呰鍏ㄦ枃</a><img src ="http://www.tkk7.com/wshao/aggbug/408255.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wshao/" target="_blank">鍗堝悗鏄熸湡鍗?/a> 2013-12-31 13:46 <a href="http://www.tkk7.com/wshao/archive/2013/12/31/408255.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Spring AOP + AspectJ frameworkhttp://www.tkk7.com/wshao/archive/2013/12/31/408253.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 05:43:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408253.htmlhttp://www.tkk7.com/wshao/comments/408253.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408253.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408253.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408253.html闃呰鍏ㄦ枃

]]>
hibernate one-to-many many-to-one 鍙屽悜娉ㄨВhttp://www.tkk7.com/wshao/archive/2013/12/31/408251.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 05:34:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408251.htmlhttp://www.tkk7.com/wshao/comments/408251.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408251.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408251.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408251.html
Hibernate 3.3.1 
Maven 3.0.4 
MySQL 5.5.13 
Myeclipse 8.6.1 

寤鴻〃璇彞錛?/p>

DROP TABLE IF EXISTS `t_company`;
CREATE TABLE `t_company` (
  `companyId` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `companyName` varchar(30) NOT NULL,
  PRIMARY KEY (`companyId`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=gb2312;

INSERT INTO `t_company` VALUES ('1', 'Sun');
INSERT INTO `t_company` VALUES ('2', 'Apache');
DROP TABLE IF EXISTS `t_employee`;
CREATE TABLE `t_employee` (
  `employeeId` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `employeeName` varchar(15) NOT NULL,
  `cid` int(10) unsigned NOT NULL,
  PRIMARY KEY (`employeeId`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=gb2312;

INSERT INTO `t_employee` VALUES ('1', 'Tom', '1');
INSERT INTO `t_employee` VALUES ('2', 'Summ', '1');
INSERT INTO `t_employee` VALUES ('3', 'Cat', '2');
INSERT INTO `t_employee` VALUES ('4', 'Vinylon', '1');
INSERT INTO `t_employee` VALUES ('5', 'Dog', '2');

鐩綍緇撴瀯錛?/p>

Employee.java

package com.fancy.po;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
 * -----------------------------------------
 * @鏂囦歡: Employee.java
 * @浣滆? fancy
 * @閭: fancyzero@yeah.net
 * @鏃墮棿: 2012-6-10
 * @鎻忚堪: 瀹炰綋綾?
 * -----------------------------------------
 */
/**
 * 涓嬮潰鍙@ManyToOne,濡傞渶浜嗚В鍏朵粬娉ㄨВ,
 * 鍙互鍙傝冧笂涓綃囷細http://www.cnblogs.com/fancyzero/archive/2012/06/10/hibernate-one-to-one-annotation.html
 */
@Entity
@Table(name = "t_employee")
public class Employee {

    private Integer employeeId;
    private String  employeeName;
    private Company company;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Integer getEmployeeId() {
        return employeeId;
    }
    /**
     * @ManyToOne錛氬瀵逛竴,cascade錛氱駭鑱?璇峰弬鑰冧笂涓綃?
      * fetch = FetchType.LAZY,寤惰繜鍔犺澆絳栫暐,濡傛灉涓嶆兂寤惰繜鍔犺澆鍙互鐢‵etchType.EAGER
     */
    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH},fetch = FetchType.LAZY)
    @JoinColumn(name = "cid")
    public Company getCompany() {
        return company;
    }
    public String getEmployeeName() {
        return employeeName;
    }
    public void setEmployeeId(Integer employeeId) {
        this.employeeId = employeeId;
    }
    public void setEmployeeName(String employeeName) {
        this.employeeName = employeeName;
    }
    public void setCompany(Company company) {
        this.company = company;
    }
}

 

Company.java

package com.fancy.po;

import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
 * -----------------------------------------
 * @鏂囦歡: Company.java
 * @浣滆? fancy
 * @閭: fancyzero@yeah.net
 * @鏃墮棿: 2012-6-10
 * @鎻忚堪: 瀹炰綋綾?
 * -----------------------------------------
 */
/**
 * 涓嬮潰鍙@OneToMany,濡傞渶浜嗚В鍏朵粬娉ㄨВ,
 * 鍙互鍙傝冧笂涓綃囷細http://www.cnblogs.com/fancyzero/archive/2012/06/10/hibernate-one-to-one-annotation.html
 */
@Entity
@Table(name = "t_company")
public class Company {

    private Integer companyId;
    private String  companyName;
    private Set<Employee> employees;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Integer getCompanyId() {
        return companyId;
    }
    /**
     * @OneToMany 涓?OneToOne鐩鎬技鐨勪篃鐢╩appedBy,鍙傝冧簡Employee
     * 鍙互鍙傝冧笂涓綃?
     */
    @OneToMany(mappedBy = "company")
    public Set<Employee> getEmployees() {
        return employees;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyId(Integer companyId) {
        this.companyId = companyId;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    public void setEmployees(Set<Employee> employees) {
        this.employees = employees;
    }
}

 

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.fancy</groupId>
  <artifactId>hibernate-annotation-many-to-one-example</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>hibernate-annotation-many-to-one-example</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  
  <dependencies>
    <!-- hibernate jar -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>3.3.1.ga</version>
    </dependency>
    <!-- hibernate annotation jar -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-annotations</artifactId>
      <version>3.3.1.GA</version>
    </dependency>
    <!-- mysql -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.17</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  
</project>


Test.java

package com.fancy.test;

import java.util.Iterator;
import java.util.Set;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import com.fancy.po.Company;
import com.fancy.po.Employee;
/**
 * -----------------------------------------
 * @鏂囦歡: Test.java
 * @浣滆? fancy
 * @閭: fancyzero@yeah.net
 * @鏃墮棿: 2012-6-10
 * @鎻忚堪: 嫻嬭瘯綾?
 * -----------------------------------------
 */
public class Test {

    public static void main(String[] args) {
        //璇誨彇hibernate閰嶇疆,榛樿璇誨彇classpath涓嬬殑hibernate.cfg.xml
        Configuration conf = new AnnotationConfiguration();    
        //鏋勫緩session宸ュ巶
         SessionFactory sessionFactory = conf.configure().buildSessionFactory();
        //鎵撳紑session
        Session session = sessionFactory.openSession();
        //寮濮嬩簨鍔?/span>
         session.beginTransaction();
        // * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        //test1(session);   //嫻嬭瘯 1
        //test2(session);  //嫻嬭瘯  2
        test3(session);   //嫻嬭瘯   3
        // * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        //鎻愪氦浜嬪姟
         session.getTransaction().commit();
        //鍏抽棴session宸ュ巶
         sessionFactory.close();
        //鍏抽棴session
        session.close();
    }
    public static void test1(Session session){
        Company company = (Company)session.get(Company.class, 1); //鍙戝嚭Company鐨剆elect璇彞
         Set<Employee> employee = company.getEmployees();         //涓嶅彂鍑篍mployee鐨剆elect璇彞
         System.out.println("Company 錛? + company.getCompanyName());
        System.out.println("CountSum錛? + employee.size()); //Employee鍒濇琚嬌鐢?鍙戝嚭select璇彞
         Iterator<Employee> it = employee.iterator(); //Employee涓嶅啀鍙戝嚭select璇彞
         while(it.hasNext()){
          System.out.println("EmployeeName錛? + it.next().getEmployeeName());
        }
    }
    public static void test2(Session session){
       Company company = (Company)session.get(Company.class, 2);//鍙戝嚭Company鐨剆elect璇彞
        Set<Employee> employee = company.getEmployees();        //涓嶅彂鍑篍mployee鐨剆elect璇彞
        Iterator<Employee> it = employee.iterator(); //鍙戝嚭Employee鐨剆elect璇彞
        Employee e = null;
       Boolean first = false;
       while(it.hasNext()){
          e = it.next();
          if(!first){
              System.out.println("EmployeeId錛歔" + e.getEmployeeId() + "] information will be change");
              e.setEmployeeName("fancy"); //鏇存敼闆囧憳鍚嶅瓧
            //  session.save(e);  //鍙戝嚭Employee鐨剈pdate璇彞,涓嶅彂鍑篊ompany鐨剈pdate璇彞
                session.save(company);    //鍙戝嚭Employee鐨剈pdate璇彞,涓嶅彂鍑篊ompany鐨剈pdate璇彞
                first = true;
            }
            System.out.println("EmployeeName錛? + e.getEmployeeName());
        }
    }
    public static void test3(Session session){
        Employee employee = (Employee)session.get(Employee.class, 1);//鍙戝嚭Employee鐨剆elect璇彞
         Company  company  = (Company)session.get(Company.class, 1);//鍙戝嚭Company鐨剆elect璇彞
         company.setCompanyName("Oracle"); //鏇存敼鍏徃鍚嶅瓧
    //  session.save(company);//鍙戝嚭Company鐨剈pdate璇彞,涓嶅彂鍑篍mployee鐨剈pdate璇彞
         session.save(employee);//鍙戝嚭Company鐨剈pdate璇彞,涓嶅彂鍑篍mployee鐨剈pdate璇彞
    }
}

 




   [ 杞澆鍑哄錛?a href="http://www.tkk7.com/fancydeepin" target="_blank">http://www.tkk7.com/fancydeepin ]


]]>
hibernate annotation 鍙屽悜 one-to-one 娉ㄨВhttp://www.tkk7.com/wshao/archive/2013/12/31/408250.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 05:33:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408250.htmlhttp://www.tkk7.com/wshao/comments/408250.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408250.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408250.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408250.html
Hibernate 3.3.1 
Maven 3.0.4 
MySQL 5.5.13 
Myeclipse 8.6.1 

 

 寤鴻〃璇彞錛?/p>

DROP TABLE IF EXISTS `t_card`;
CREATE TABLE `t_card` (
  `cardId` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `cardNumber` char(18) NOT NULL,
  PRIMARY KEY (`cardId`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=gb2312;

INSERT INTO `t_card` VALUES ('1', '440911199008011122');
DROP TABLE IF EXISTS `t_person`;
CREATE TABLE `t_person` (
  `personId` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `personName` varchar(15) NOT NULL,
  `cid` int(10) unsigned NOT NULL,
  PRIMARY KEY (`personId`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=gb2312;

INSERT INTO `t_person` VALUES ('1', 'fancy', '1');

 

Person.java

package com.fancy.po;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
/**
 * -----------------------------------------
 * @鏂囦歡: Person.java
 * @浣滆? fancy
 * @閭: fancyzero@yeah.net
 * @鏃墮棿: 2012-6-10
 * @鎻忚堪: 瀹炰綋綾?
 * -----------------------------------------
 */
/**
 * @Entity 澹版槑涓涓被涓哄疄浣揃ean
 * @Table(name = "xx")鎸囧畾瀹炰綋綾繪槧灝勭殑琛?濡傛灉琛ㄥ悕鍜屽疄浣撶被鍚嶄竴鑷?鍙互涓嶆寚瀹?
 */
@Entity
@Table(name = "t_person")
public class Person {

    private Integer personId;
    private String  personName;
    private Card    card;
    /**
     * @Id 鏄犲皠涓婚敭灞炴?榪欓噷閲囩敤uuid鐨勪富閿敓鎴愮瓥鐣?
      * @GeneratedValue —— 娉ㄨВ澹版槑浜嗕富閿殑鐢熸垚絳栫暐銆傝娉ㄨВ鏈夊涓嬪睘鎬?
      * strategy 鎸囧畾鐢熸垚鐨勭瓥鐣?榛樿鏄疓enerationType. AUTO
     * GenerationType.AUTO 涓婚敭鐢辯▼搴忔帶鍒?
      * GenerationType.TABLE 浣跨敤涓涓壒瀹氱殑鏁版嵁搴撹〃鏍兼潵淇濆瓨涓婚敭
      * GenerationType.IDENTITY 涓婚敭鐢辨暟鎹簱鑷姩鐢熸垚,涓昏鏄嚜鍔ㄥ闀跨被鍨?
      * GenerationType.SEQUENCE 鏍規嵁搴曞眰鏁版嵁搴撶殑搴忓垪鏉ョ敓鎴愪富閿紝鏉′歡鏄暟鎹簱鏀寔搴忓垪
      * generator 鎸囧畾鐢熸垚涓婚敭浣跨敤鐨勭敓鎴愬櫒
      */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Integer getPersonId() {
        return personId;
    }
    /**
     * @OneToOne錛氫竴瀵逛竴鍏寵仈
      * cascade錛氱駭鑱?瀹冨彲浠ユ湁鏈変簲涓煎彲閫?鍒嗗埆鏄細
      * CascadeType.PERSIST錛氱駭鑱旀柊寤?
      * CascadeType.REMOVE : 綰ц仈鍒犻櫎
      * CascadeType.REFRESH錛氱駭鑱斿埛鏂?
      * CascadeType.MERGE  錛?綰ц仈鏇存柊
      * CascadeType.ALL    錛?浠ヤ笂鍏ㄩ儴鍥涢」
      * @JoinColumn:涓昏〃澶栭敭瀛楁
      * cid錛歅erson鎵鏄犲皠鐨勮〃涓殑涓涓瓧孌?
      */
    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "cid")
    public Card getCard() {
        return card;
    }
    public String getPersonName() {
        return personName;
    }
    public void setPersonId(Integer personId) {
        this.personId = personId;
    }
    public void setPersonName(String personName) {
        this.personName = personName;
    }
    public void setCard(Card card) {
        this.card = card;
    }
}

 

Card.java

package com.fancy.po;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
/**
 * -----------------------------------------
 * @鏂囦歡: Card.java
 * @浣滆? fancy
 * @閭: fancyzero@yeah.net
 * @鏃墮棿: 2012-6-10
 * @鎻忚堪: 瀹炰綋綾?
 * -----------------------------------------
 */
@Entity
@Table(name = "t_card")
public class Card {

    private Integer cardId;
    private String  cardNumber;
    private Person  person;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Integer getCardId() {
        return cardId;
    }
    /**
     * @OneToOne錛氫竴瀵逛竴鍏寵仈
      * mappedBy = "card"錛氭剰鎬濇槸璇磋繖閲岀殑涓瀵逛竴閰嶇疆鍙傝冧簡card
     * card鍙堟槸浠涔堝憿?card鏄疨erson綾諱腑鐨刧etCard(),娉ㄦ剰涓嶆槸Person綾諱腑鐨?
      * card灞炴?Person綾諱腑鐨凮neToOne閰嶇疆灝辨槸鍦╣etCard()鏂規硶涓婇潰閰嶇殑.
     * 濡傛灉Person綾諱腑鐨刧etCard()鏂規硶鏀規垚getIdCard(),鍏朵粬涓嶅彉鐨勮瘽,
     * 榪欓噷灝辮鍐欐垚錛歮appedBy = "idCard"
     */
    @OneToOne(mappedBy = "card")
    public Person getPerson() {
        return person;
    }
    public String getCardNumber() {
        return cardNumber;
    }
    public void setCardId(Integer cardId) {
        this.cardId = cardId;
    }
    public void setCardNumber(String cardNumber) {
        this.cardNumber = cardNumber;
    }
    public void setPerson(Person person) {
        this.person = person;
    }
}

 

 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.fancy</groupId>
  <artifactId>hibernate-annotation-on-to-one-example</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>hibernate-annotation-on-to-one-example</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  
  <dependencies>
    <!-- hibernate jar -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>3.3.1.ga</version>
    </dependency>
    <!-- hibernate annotation jar -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-annotations</artifactId>
      <version>3.3.1.GA</version>
    </dependency>
    <!-- mysql -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.17</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  
</project>

 

Test.java

package com.fancy.test;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import com.fancy.po.Card;
import com.fancy.po.Person;
/**
 * -----------------------------------------
 * @鏂囦歡: Test.java
 * @浣滆? fancy
 * @閭: fancyzero@yeah.net
 * @鏃墮棿: 2012-6-10
 * @鎻忚堪: 嫻嬭瘯綾?
 * -----------------------------------------
 */
public class Test {

    public static void main(String[] args) {
        
        //璇誨彇hibernate閰嶇疆,榛樿璇誨彇classpath涓嬬殑hibernate.cfg.xml
        Configuration conf = new AnnotationConfiguration();    
        //鏋勫緩session宸ュ巶
         SessionFactory sessionFactory = conf.configure().buildSessionFactory();
        //鎵撳紑session
        Session session = sessionFactory.openSession();
        //寮濮嬩簨鍔?/span>
         session.beginTransaction();
        // * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        //test1(session);    //嫻嬭瘯 1
        //test2(session);    //嫻嬭瘯 2
        test3(session);      //嫻嬭瘯 3
        // * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        //鎻愪氦浜嬪姟
         session.getTransaction().commit();
        //鍏抽棴session宸ュ巶
         sessionFactory.close();
       //鍏抽棴session
       session.close();
    }
    /**
     * 鏁版嵁搴撳垵濮嬪鹼細
      * personName錛歠ancy
     * cardNumber錛?40911199008011122
     */
    //嫻嬭瘯鏂規硶1
    public static void test1(Session session){
        Person person = (Person)session.get(Person.class, 1); //鍙戝嚭Person鍜孋ard鐨剆elect璇彞
         Card card = person.getCard();
        System.out.println(person.getPersonName());
        System.out.println(card.getCardNumber());
        person.setPersonName("fancy");            //涓庡垵濮嬪間竴鑷?/span>
         card.setCardNumber("440911199008011122");//涓庡垵濮嬪間竴鑷?/span>
         session.save(person);    //涓嶅彂鍑簊ql璇彞
       //session.save(card);     //涓嶅彂鍑簊ql璇彞
    }
    //嫻嬭瘯鏂規硶2
    public static void test2(Session session){
        Person person = (Person)session.get(Person.class, 1); //鍙戝嚭Person鍜孋ard鐨剆elect璇彞
         Card card = person.getCard();
        System.out.println(person.getPersonName());
        System.out.println(card.getCardNumber());
        person.setPersonName("fancyzero");        //涓庡垵濮嬪間笉涓鑷?/span>
         card.setCardNumber("440911199008011122");//涓庡垵濮嬪間竴鑷?/span>
         session.save(person);    //鍙戝嚭Person鐨剈pdate璇彞,鏁版嵁搴撲腑personName琚慨鏀?涓嶅彂鍑篊ard鐨剈pdate璇彞
       //session.save(card);     //鍙戝嚭Person鐨剈pdate璇彞,鏁版嵁搴撲腑personName琚慨鏀?涓嶅彂鍑篊ard鐨剈pdate璇彞
    }
    //嫻嬭瘯鏂規硶3
    public static void test3(Session session){
        Person person = (Person)session.get(Person.class, 1); //鍙戝嚭Person鍜孋ard鐨剆elect璇彞
         Card card = person.getCard();
        System.out.println(person.getPersonName());
        System.out.println(card.getCardNumber());
        person.setPersonName("fancy");           //涓庡垵濮嬪間笉涓鑷?/span>
         card.setCardNumber("440911199008080808");//涓庡垵濮嬪間笉涓鑷?/span>
         session.save(person);    //鍚屾椂鍙戝嚭Person鍜孋ard鐨剈pdate璇彞,鏁版嵁搴撲腑鐨勬暟鎹浉搴旇淇敼
       //session.save(card);     //鍚屾椂鍙戝嚭Person鍜孋ard鐨剈pdate璇彞,鏁版嵁搴撲腑鐨勬暟鎹浉搴旇淇敼
    }
}

 




   [杞澆鍑哄錛?a href="http://www.tkk7.com/fancydeepin" target="_blank">http://www.tkk7.com/fancydeepin ]



]]>
hibernate annotation 涔?娉ㄨВ澹版槑http://www.tkk7.com/wshao/archive/2013/12/31/408249.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 05:30:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408249.htmlhttp://www.tkk7.com/wshao/comments/408249.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408249.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408249.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408249.html@Entity

     灝嗕竴涓?POJO 綾繪敞瑙f垚涓涓疄浣?bean ( 鎸佷箙鍖?POJO 綾?)

@Table

    涓哄疄浣?bean 鏄犲皠鎸囧畾鍏蜂綋鐨勮〃錛屽鏋滆娉ㄨВ娌℃湁琚0鏄庯紝緋葷粺灝嗕嬌鐢ㄩ粯璁ゅ?( 鍗沖疄浣?bean 涓嶅甫鍖呭悕鐨勭煭綾誨悕 )

@Id

    灝嗗疄浣揵ean涓殑鏌愪釜灞炴у畾涔変負鏍囪瘑絎?( identifier )

@GeneratedValue

    璇ユ敞瑙e彲浠ュ畾涔夎鏍囪瘑絎︾殑鐢熸垚絳栫暐 ( 榛樿鏄?AUTO 絳栫暐 ) :

    AUTO — 鍙互鏄?IDENTITY錛屾垨 SEQUENCE 鎴?TABLE 綾誨瀷錛岃繖鍙栧喅浜庝笉鍚岀殑搴曞眰鏁版嵁搴撱?br />
    TABLE — 浣跨敤琛ㄤ繚瀛榠d鍊?br />
    IDENTITY — 鑷劧閫掑

    SEQUENCE — 搴忓垪

@Transient

     琚敞瑙f垚 @Transient 鐨?getter 鏂規硶鎴栧睘鎬э紝灝嗕笉浼氳鎸佷箙鍖栵紝hibernate 浼氬拷鐣ヨ繖浜涘瓧孌靛拰灞炴с?br />
@Basic

    鎵鏈夋病鏈夊畾涔夋敞瑙g殑灞炴э紝絳変環浜庡湪鍏朵笂闈㈡坊鍔犱簡 @Basic 娉ㄨВ.銆傞氳繃 @Basic娉ㄨВ鍙互澹版槑灞炴х殑鑾峰彇絳栫暐 ( fetch strategy )

@Temporal

    鍦ㄦ牳蹇冪殑 Java API 涓茍娌℃湁瀹氫箟鏃墮棿綺懼害 ( temporal precision )銆傚洜姝ゅ鐞嗘椂闂寸被鍨嬫暟鎹椂錛屼綘榪橀渶瑕佸畾涔夊皢鍏跺瓨鍌ㄥ湪鏁版嵁搴撲腑鎵棰勬湡鐨勭簿搴︺?br />
    鍦ㄦ暟鎹簱涓紝琛ㄧず鏃墮棿綾誨瀷鐨勬暟鎹湁 DATE錛孴IME錛屽拰 TIMESTAMP 涓夌綺懼害 ( 鍗沖崟綰殑鏃ユ湡錛屾椂闂達紝鎴栬呬袱鑰呭吋澶?)銆?鍙嬌鐢?@Temporal 娉ㄨВ鏉ヨ皟鏁寸簿搴︺?br />
@Column 

    灝嗗疄浣?bean 涓殑灞炴ф槧灝勫埌琛ㄤ腑鐨勫垪銆?br />
    @Column(

        name = "columnName";                                (1)

        boolean unique() default false                 (2)

        boolean nullable() default true               (3)

        boolean insertable() default true           (4)

        boolean updatable() default true           (5)

        String columnDefinition() default ""      (6)

        String table() default ""                               (7)

        int length() default 255                              (8)

        int precision() default 0                             (9)

        int scale() default 0                                     (10)

(1)     name 鍙夛紝鍒楀悕(榛樿鍊兼槸灞炴у悕)

(2)     unique 鍙?font size="2">錛?/font>鏄惁鍦ㄨ鍒椾笂璁劇疆鍞竴綰︽潫(榛樿鍊糵alse)

(3)     nullable 鍙?font size="2">錛?/font>鏄惁璁劇疆璇ュ垪鐨勫煎彲浠ヤ負絀?榛樿鍊紅rue)

(4)     insertable 鍙?font size="2">錛?/font>璇ュ垪鏄惁浣滀負鐢熸垚鐨刬nsert璇彞涓殑涓涓垪(榛樿鍊紅rue)

(5)     updatable 鍙?font size="2">錛?/font>璇ュ垪鏄惁浣滀負鐢熸垚鐨剈pdate璇彞涓殑涓涓垪(榛樿鍊紅rue)

(6)     columnDefinition 鍙?font size="2">錛?/font>涓鴻繖涓壒瀹氬垪瑕嗙洊SQL DDL鐗囨 (榪欏彲鑳藉鑷存棤娉曞湪涓嶅悓鏁版嵁搴撻棿縐繪)

(7)     table 鍙?font size="2">錛?/font>瀹氫箟瀵瑰簲鐨勮〃(榛樿涓轟富琛?

(8)     length 鍙?font size="2">錛?/font>鍒楅暱搴?榛樿鍊?55)

(9)     precision 鍙?font size="2">錛?/font>鍒楀崄榪涘埗綺懼害(decimal precision)(榛樿鍊?)

(10)  scale 鍙?font size="2">錛?/font>濡傛灉鍒楀崄榪涘埗鏁板艱寖鍥?decimal scale)鍙敤,鍦ㄦ璁劇疆(榛樿鍊?)

 [ 杞澆鍑哄錛?a href="http://www.tkk7.com/fancydeepin" target="_blank">http://www.tkk7.com/fancydeepin ]


]]>
hibernate annotation 涔?涓婚敭鐢熸垚絳栫暐http://www.tkk7.com/wshao/archive/2013/12/31/408248.html鍗堝悗鏄熸湡鍗?/dc:creator>鍗堝悗鏄熸湡鍗?/author>Tue, 31 Dec 2013 05:29:00 GMThttp://www.tkk7.com/wshao/archive/2013/12/31/408248.htmlhttp://www.tkk7.com/wshao/comments/408248.htmlhttp://www.tkk7.com/wshao/archive/2013/12/31/408248.html#Feedback0http://www.tkk7.com/wshao/comments/commentRss/408248.htmlhttp://www.tkk7.com/wshao/services/trackbacks/408248.htmlHibernate 榛樿鎬誨叡鏀寔 13 縐嶇敓鎴愮瓥鐣?:

1. increment        2.  identity        3. sequence

4. hilo                  5. seqhilo         6. uuid

7. uuid.hex          8. guid             9. native

10. assigned       11. select         12. foreign        13. sequence-identity

 

涓嬮潰浠嬬粛鍑犱釜杈冧負甯哥敤鐨勭瓥鐣?:

① identity [ 鑷劧閫掑 ]

         鏀寔 DB2錛孧ySQL錛孲QL Server錛孲ybase 鍜孒ypersonicSQL 鏁版嵁搴擄紝 鐢ㄤ簬涓?long 鎴?short 鎴?int 綾誨瀷鐢熸垚鍞竴鏍囪瘑銆傚畠渚濊禆浜庡簳灞備笉鍚岀殑鏁版嵁搴擄紝
       涓?Hibernate 鍜?紼嬪簭鍛樻棤鍏熾?br />

娉ㄨВ紺轟緥 :

@Id

@GenericGenerator(name = "idGenerator", strategy = "identity")

@GeneratedValue(generator = "idGenerator")

 

② sequence [ 搴忓垪 ]

鏀寔 Oracle錛孌B2錛孭ostgreSql錛孲APDb 絳夋暟鎹簱錛岀敤浜庝負 long 鎴?short 鎴?int 綾誨瀷鐢熸垚鍞竴鏍囪瘑銆傚畠闇瑕佸簳灞傛暟鎹簱鐨勬敮鎸侊紝
       騫剁敱鏁版嵁搴撴潵緇存姢榪欎釜 sequence 搴忓垪銆?/span>

娉ㄨВ紺轟緥 :

@Id

   @GenericGenerator(name = "idGenerator", strategy = "sequence",

parameters = {@Parameter(name = "sequence",value="seq_name")})

   @GeneratedValue(generator = "idGenerator")

娉ㄦ剰 : 璇ョ瓥鐣ヨ姹傝瀹氬簭鍒楀悕錛屽惁鍒?hibernate 灝嗘棤娉曟壘鍒幫紝榪欏皢寮曡嚧鎶涘嚭寮傚父 :

org.hibernate.exception.SQLGrammarException: could not get next sequence value

 

③ native

         闇搴曞眰鏁版嵁搴撶殑鏀寔錛屽浜?MySQL錛孲QL Server 閲囩敤 identity 鐨勭敓鎴愮瓥鐣ワ紝瀵逛簬 Oracle錛屽垯閲囩敤 sequence 絳栫暐銆?/span>

娉ㄨВ紺轟緥 :

@Id

   @GenericGenerator(name = "idGenerator", strategy = "native")

   @GeneratedValue(generator = "idGenerator")

 

④ increment [ 鑷劧閫掑 ]

       涓?identity 絳栫暐涓嶅悓鐨勬槸錛岃絳栫暐涓嶄緷璧栦簬搴曞眰鏁版嵁搴擄紝鑰屼緷璧栦簬 hibernate 鏈韓錛岀敤浜庝負 long 鎴?short 鎴?int 綾誨瀷鐢熸垚鍞竴鏍囪瘑銆?br />       涓婚敭璁℃暟鍣ㄦ槸鐢?hibernate 鐨勪竴涓疄渚嬫潵緇存姢錛屾瘡嬈¤嚜澧為噺涓?1錛屼絾鍦ㄩ泦緹や笅涓嶈兘浣跨敤璇ョ瓥鐣ワ紝
       鍚﹀垯灝嗗紩璧蜂富閿啿紿佺殑鎯呭喌錛岃絳栫暐閫傜敤浜庢墍鏈夊叧緋誨瀷鏁版嵁搴撲嬌鐢ㄣ?/span>

娉ㄨВ紺轟緥 :

       @Id

   @GenericGenerator(name = "idGenerator", strategy = "increment")

   @GeneratedValue(generator = "idGenerator")

 

⑤ uuid [ 32浣?6榪涘埗鏁扮殑瀛楃涓?]

         閲囩敤128浣峌UID綆楁硶鐢熸垚涓婚敭錛岃兘澶熶繚璇佺綉緇滅幆澧冧笅鐨勪富閿敮涓鎬э紝涔熷氨鑳藉淇濊瘉鍦ㄤ笉鍚屾暟鎹簱鍙婁笉鍚屾湇鍔″櫒涓嬩富閿殑鍞竴鎬с?br />       uuid 鏈緇堣緙栫爜鎴愪竴涓?2浣?6榪涘埗鏁扮殑瀛楃涓詫紝
       鍗犵敤鐨勫瓨鍌ㄧ┖闂磋緝澶с傜敤浜庝負 String 綾誨瀷鐢熸垚鍞竴鏍囪瘑錛岄傜敤浜庢墍鏈夊叧緋誨瀷鏁版嵁搴撱?/span>

娉ㄨВ紺轟緥 :

       @Id

   @GenericGenerator(name = "idGenerator", strategy = "uuid")

   @GeneratedValue(generator = "idGenerator")

 

⑤ assigned [ 鎵嬪伐鍒嗛厤涓婚敭ID鍊?]

       璇ョ瓥鐣ヨ姹傜▼搴忓憳蹇呴』鑷繁緇存姢鍜岀鐞嗕富閿紝褰撴湁鏁版嵁闇瑕佸瓨鍌ㄦ椂錛岀▼搴忓憳蹇呴』鑷繁涓鴻鏁版嵁鍒嗛厤鎸囧畾涓涓富閿甀D鍊鹼紝
       濡傛灉璇ユ暟鎹病鏈夎鍒嗛厤涓婚敭ID鍊兼垨鍒嗛厤鐨勫煎瓨鍦ㄩ噸澶嶏紝鍒欒鏁版嵁閮藉皢鏃犳硶琚寔涔呭寲涓斾細寮曡搗寮傚父鐨勬姏鍑恒?/span>

娉ㄨВ紺轟緥 :

       @Id

   @GenericGenerator(name = "idGenerator", strategy = "assigned")

   @GeneratedValue(generator = "idGenerator")


 [杞澆鍑哄錛?a href="http://www.tkk7.com/fancydeepin" target="_blank">http://www.tkk7.com/fancydeepin ]



]]>
主站蜘蛛池模板: 亚洲国产精品综合一区在线| 特级无码毛片免费视频尤物| 亚洲精品视频在线免费| 亚洲人成人无码网www国产| 最近的免费中文字幕视频| 久草免费福利资源站| 一边摸一边爽一边叫床免费视频 | 羞羞网站免费观看| 亚洲综合无码无在线观看| 91精品国产亚洲爽啪在线影院 | 男女猛烈无遮掩视频免费软件| 亚洲伊人久久大香线蕉| 亚洲综合自拍成人| 亚洲AV成人无码久久精品老人| 亚洲视频在线一区二区| 国产免费人成在线视频| 成人免费无码大片A毛片抽搐| 国产1000部成人免费视频| 99久久综合精品免费| 久久国产免费观看精品| 丝袜捆绑调教视频免费区| 人与动性xxxxx免费| 男女作爱免费网站| 又硬又粗又长又爽免费看| 深夜久久AAAAA级毛片免费看| 国产成人综合亚洲| 亚洲AV无码男人的天堂| 亚洲色偷偷综合亚洲av78| 国产午夜亚洲精品国产| 亚洲一区二区影视| 亚洲精品一二三区| 亚洲kkk4444在线观看| 亚洲人成色777777精品| 久久夜色精品国产噜噜亚洲a| 亚洲熟妇AV日韩熟妇在线| 亚洲色偷偷综合亚洲AV伊人蜜桃| 亚洲国产无线乱码在线观看 | 午夜老司机免费视频| 日韩免费视频一区| 亚洲国产精品专区在线观看 | eeuss影院ss奇兵免费com|