锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 浣跨敤@RequestParam鏃訛紝URL鏄繖鏍風(fēng)殑錛歨ttp://host:port/path?鍙傛暟鍚?鍙傛暟鍊?br style="margin: 0px; padding: 0px;" /> 浣跨敤@PathVariable鏃訛紝URL鏄繖鏍風(fēng)殑錛歨ttp://host:port/path/鍙傛暟鍊?br style="margin: 0px; padding: 0px;" /> 渚嬪錛?/p> 涓婇潰涓や釜鏂規(guī)硶錛岃闂礬寰勫垎鍒涓嬶細(xì)
]]>
]]>
妤間富鎴戜篃鏄嫤鎬濊壇涔咃紝涓嶇粡鎰忛棿鐪嬪埌浜嗗悗鍙扮殑鏃ュ織錛屾墠鍙戠幇鏄痵pring鎼炵殑楝箋?/span>
鎶ラ敊淇℃伅錛?span style="box-sizing: border-box; margin: 0px; padding: 0px; color: #ff0000;"><No mapping found for HTTP request with URI [/sandDemo001/images/1.jpg] in DispatcherServlet with name 'spring'>
瑙e喅鏂規(guī)硶1錛?span style="box-sizing: border-box; margin: 0px; padding: 0px; font-size: 14px;">鍦╯pring鐨勯厤緗慨鏀?/strong>web.xml涓嬪spring鐨?/strong>DispatcherServlet璇鋒眰url鏄犲皠鐨勯厤緗紝鍏堟潵鐪嬬湅鍘熼厤緗?/strong>錛?/span>
瑙e喅鏂規(guī)硶2錛?span style="box-sizing: border-box; margin: 0px; padding: 0px; color: #000000; font-size: 14px;">鍦╯pring鐨勯厤緗枃浠朵腑娣誨姞濡備笅涓琛岋細(xì)
<mvc:default-servlet-handler/>
娉ㄦ剰錛岄渶瑕佹槸spring3.0.5浠ヤ笂鐗堟湰
鎽樿嚜錛?a style="text-decoration: none; color: #000000;">http://www.oschina.net/p/fastdfs
FastDFS鏄竴涓紑婧愮殑鍒嗗竷寮忔枃浠剁郴緇燂紝濂瑰鏂囦歡榪涜綆$悊錛屽姛鑳藉寘鎷細(xì)鏂囦歡瀛樺偍銆佹枃浠跺悓姝ャ佹枃浠惰闂紙鏂囦歡涓婁紶銆佹枃浠朵笅杞斤級絳夛紝瑙e喅浜嗗ぇ瀹歸噺瀛樺偍鍜岃礋杞藉潎琛$殑闂銆傜壒鍒傚悎浠ユ枃浠朵負(fù)杞戒綋鐨勫湪綰挎湇鍔★紝濡傜浉鍐岀綉绔欍佽棰戠綉绔欑瓑絳夈?/p>
FastDFS鏈嶅姟绔湁涓や釜瑙掕壊錛氳窡韙櫒錛坱racker錛夊拰瀛樺偍鑺傜偣錛坰torage錛夈傝窡韙櫒涓昏鍋氳皟搴﹀伐浣滐紝鍦ㄨ闂笂璧瘋礋杞藉潎琛$殑浣滅敤銆?/p>
瀛樺偍鑺傜偣瀛樺偍鏂囦歡錛屽畬鎴愭枃浠剁鐞嗙殑鎵鏈夊姛鑳斤細(xì)瀛樺偍銆佸悓姝ュ拰鎻愪緵瀛樺彇鎺ュ彛錛孎astDFS鍚屾椂瀵規(guī)枃浠剁殑meta data榪涜綆$悊銆傛墍璋撴枃浠剁殑meta data灝辨槸鏂囦歡鐨勭浉鍏沖睘鎬э紝浠ラ敭鍊煎錛坘ey value pair錛夋柟寮忚〃紺猴紝濡傦細(xì)width=1024錛屽叾涓殑key涓簑idth錛寁alue涓?024銆傛枃浠秏eta data鏄枃浠跺睘鎬у垪琛紝鍙互鍖呭惈澶氫釜閿煎銆?/p>
GitHub錛?a style="text-decoration: none; color: #000000;">https://github.com/happyfish100/fastdfs
涓涓啓鐨勪笉閿欑殑鍗氬錛?a style="text-decoration: none; color: #000000;">http://tech.uc.cn/?p=221
鍙傝冩枃妗o細(xì)
https://github.com/happyfish100/fastdfs/blob/master/INSTALL
yum -y groupinstall 'Development Tools' yum -y install wget
蹇呴』鍏堟寜鐓ц繖涓紝鍚﹀垯鎶ラ敊錛?/p>
cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O -DDEBUG_FLAG -DOS_LINUX -DIOEVENT_USE_EPOLL -c -o ../common/fdfs_global.o ../common/fdfs_global.c -I../common -I/usr/include/fastcommon ../common/fdfs_global.c:20:20: fatal error: logger.h: No such file or directory #include "logger.h" ^ compilation terminated. ........
鐩存帴涓嬭澆瀹夎鍗沖彲錛?/p>
wget https://github.com/happyfish100/libfastcommon/archive/master.zip unzip master.zip cd libfastcommon-master ./make.sh ./make.sh install
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz tar -zxvf V5.05.tar.gz cd fastdfs-5.05/ ./make.sh ./make.sh install
瀹夎涔嬪悗閰嶇疆鏂囦歡鍦ㄧ洰褰?etc/fdfs銆?/p>
mv storage.conf.sample storage.conf mv tracker.conf.sample tracker.conf
棣栧厛淇敼閰嶇疆鏂囦歡錛?nbsp;
/etc/fdfs/tracker.conf錛屼慨鏀硅礬寰勫埌/data/fdfs鐩綍銆?/p>
# the base path to store data and log files base_path=/data/fdfs
鍚姩錛?nbsp;
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
淇敼閰嶇疆鏂囦歡錛?nbsp;
/etc/fdfs/storage.conf錛屼慨鏀硅礬寰勫埌/data/fdfs鐩綍錛屽悓鏃墮厤緗畉racker_server鍦板潃銆?/p>
# the base path to store data and log files base_path=/data/fdfs # tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address tracker_server=192.168.1.36:22122 # store_path#, based 0, if store_path0 not exists, it's value is base_path # the paths must be exist store_path0=/data/fdfs #store_path1=/home/yuqing/fastdfs2
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
鍚姩鐨勬椂鍊欙紝鐪嬫棩蹇楁病鏈夐敊璇氨璇存槑鍚姩鎴愬姛銆?nbsp;
鏌ョ湅fdfs榪涚▼錛?/p>
#ps -ef | grep fdfs root 19880 1 0 21:42 ? 00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start root 20050 1 0 22:08 ? 00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start root 20060 19915 0 22:08 pts/1 00:00:00 grep --color=auto fdfs
2.5 瀹夎nginx + lua + fastdfs module
涓嬭澆fastdfs-nginx-module妯″潡
https://github.com/happyfish100/fastdfs-nginx-module
涓嬭澆openresty nginx +lua鍖?/p>
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip unzip fastdfs-nginx-module-master.zip wget http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz tar -zxvf ngx_openresty-1.7.10.1.tar.gz
緙栬瘧瀹夎錛氳繖閲屾敞鎰忎笅錛岄渶瑕佸鍔犲弬鏁般?nbsp;
涓涓槸stub_status緇熻妯″潡錛屼竴涓槸realip妯″潡銆?nbsp;
鍙傝冨湴鍧錛?nbsp;
http://blog.danielss.com/?p=80
http://wiki.nginx.org/HttpRealipModuleChs
yum -y install pcre-devel openssl openssl-devel cd ngx_openresty-1.7.10.1 ./configure --with-luajit --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --add-module=/root/fastdfs-nginx-module-master/src gmake gmake install
nginx +lua瀹夎璺緞錛?/p>
nginx path prefix: "/usr/local/openresty/nginx" nginx binary file: "/usr/local/openresty/nginx/sbin/nginx" nginx configuration prefix: "/usr/local/openresty/nginx/conf" nginx configuration file: "/usr/local/openresty/nginx/conf/nginx.conf" nginx pid file: "/usr/local/openresty/nginx/logs/nginx.pid" nginx error log file: "/usr/local/openresty/nginx/logs/error.log" nginx http access log file: "/usr/local/openresty/nginx/logs/access.log"
鍚姩錛岄噸鍚痭ginx
#鍚姩 /usr/local/openresty/nginx/sbin/nginx #閲嶅惎 /usr/local/openresty/nginx/sbin/nginx -s restart
閰嶇疆鏈嶅姟錛?/p>
cd /etc/fdfs mv client.conf.sample client.conf
淇敼閰嶇疆錛?/p>
# the base path to store log files base_path=/data/fdfs # tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address tracker_server=192.168.1.36:22122
閰嶇疆nginx錛?/p>
cp /root/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/ mkdir /data/ngx
淇敼mod_fastdfs.conf閰嶇疆鏂囦歡錛氫慨鏀箃racker绔彛錛屽惁鍒檔ginx鍚姩涓嶄簡銆傝礬寰勪篃蹇呴』淇敼錛屽惁鍒欐壘涓嶅埌鏂囦歡銆?/p>
# the base path to store log files base_path=/data/ngx # FastDFS tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address # valid only when load_fdfs_parameters_from_tracker is true tracker_server=192.168.1.36:22122 # store_path#, based 0, if store_path0 not exists, it's value is base_path # the paths must be exist # must same as storage.conf store_path0=/data/fdfs
鎷瘋礉閰嶇疆鏂囦歡錛屽惁鍒檔ginx鍚姩涓嶄簡錛屾姤閿欙細(xì)
[2015-04-28 11:30:14] ERROR - file: ini_file_reader.c, line: 315, include file "http.conf" not exists, line: "#include http.conf" [2015-04-28 11:30:14] ERROR - file: /root/fastdfs-nginx-module-master/src/common.c, line: 155, load conf file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2 2015/04/28 11:30:14 [alert] 19969#0: worker process 2753 exited with fatal code 2 and cannot be respawned
瑙e喅鍔炴硶錛?/p>
cp /root/fastdfs-master/conf/http.conf /root/fastdfs-master/conf/mime.types /etc/fdfs
nginx閰嶇疆淇敼vi /usr/local/openresty/nginx/conf/nginx.conf
server { listen 80; server_name localhost; charset utf8; location /M00 { alias /data/fdfs/data; ngx_fastdfs_module; } ......
鍒涘緩榪炴帴
ln -s /data/fdfs/data /data/fdfs/data/M00
閲嶅惎nginx銆?nbsp;
嫻嬭瘯鍛戒護錛?/p>
echo "test fastdfs" > test.html /usr/bin/fdfs_test /etc/fdfs/client.conf upload test.html
涓婁紶鎴愬姛錛屾墽琛岀粨鏋滐細(xì)
This is FastDFS client test program v5.05 Copyright (C) 2008, Happy Fish / YuQing FastDFS may be copied only under the terms of the GNU General Public License V3, which may be found in the FastDFS source kit. Please visit the FastDFS Home Page http://www.csource.org/ for more detail. [2015-04-25 18:06:09] DEBUG - base_path=/data/fdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0 tracker_query_storage_store_list_without_group: server 1. group_name=, ip_addr=192.168.1.36, port=23000 group_name=group1, ip_addr=192.168.1.36, port=23000 storage_upload_by_filename group_name=group1, remote_filename=M00/00/00/wKgC1FU7ZxGAF19vAAAADcvBslg01.html source ip address: 192.168.1.36 file timestamp=2015-04-25 18:06:09 file size=13 file crc32=3418468952 example file url: http://192.168.1.36/group1/M00/00/00/wKgC1FU7ZxGAF19vAAAADcvBslg01.html storage_upload_slave_by_filename group_name=group1, remote_filename=M00/00/00/wKgC1FU7ZxGAF19vAAAADcvBslg01_big.html source ip address: 192.168.1.36 file timestamp=2015-04-25 18:06:09 file size=13 file crc32=3418468952 example file url: http://192.168.1.36/group1/M00/00/00/wKgC1FU7ZxGAF19vAAAADcvBslg01_big.html
嫻嬭瘯璁塊棶錛?/p>
curl http://192.168.1.36/M00/00/00/wKgC1FU7ZxGAF19vAAAADcvBslg01_big.html
濡傛灉榪斿洖“test fastdfs”璇存槑閰嶇疆鎴愬姛銆備笂闈㈢殑姣忎竴姝ヤ慨鏀歸兘瑕佹紜墠鍙互銆?/p>
鏌ョ湅nginx閿欒鏃ュ織錛?nbsp;
tail -f /usr/local/openresty/nginx/logs/error.log
FastDFS闈炲父濂界殑鍒嗗竷寮忔枃浠剁郴緇熴傞厤緗畝鍗曪紝鍙互澶氭満鍣ㄩ儴緗詫紝鍚屾椂瀹樻柟緇欎簡涓涓狽ginx妯″潡錛屽彲浠ョ洿鎺ョ敤nginx璁塊棶錛岄潪甯告柟渚褲傝繖鏍峰噺灝戜簡涓棿鐨則omcat灞傦紝鏁堢巼楂樸?nbsp;
鎺ヤ笅鏉ョ戶緇爺絀秎ua鐨勫浘鐗囧帇緙┿傜洿鎺ュ湪nginx灞傝繘琛屽浘鐗囧帇緙┿傛晥鐜囨洿楂橈紝鍚屾椂鍥劇墖璇誨彇FastDFS鐨勬枃浠躲?/p>
鍦烘櫙錛氬湪Service綾諱腑浣跨敤瀛愪簨鍔?saveponit)鏃訛紝褰撳瓙浜嬪姟鎶涘嚭寮傚父鍚庯紝姝ゅ紓甯稿鐞嗘帀涓嶇戶緇線澶栨姏錛宻pring鍦ㄦ彁浜や富浜嬪姟鏃朵細(xì)鎶涘嚭
org.springframework.transaction.UnexpectedRollbackException: Transaction has been rolled back because it has been marked as rollback
鏂規(guī)硶璋冪敤緇撴瀯錛?/p>
鍋囪嫢鏈堿銆丅銆丆涓変釜Service綾伙紝鍏跺疄渚嬪璞″垎鍒負(fù)a銆乥銆乧,綾誨垎鍒畾涔夊涓嬶細(xì)
A {
鏂規(guī)硶() { //propagation="REQUIRED"
try{
b.鏂規(guī)硶();
} catch (Exception e) {
}
}
}
B{
savePoint鏂規(guī)硶() { //propagation="NESTED"
c.鏂規(guī)硶(); //濡傛灉榪欓噷杈圭殑鎿嶄綔鍏ㄦ槸鏅氱被錛堜笉鏄疭ervice綾伙級鎿嶄綔錛屼笉浼?xì)鏈夐棶棰樸?/p>
}
}
C{
鏂規(guī)硶() { //propagation="REQUIRED"
throw new Exception("鍑洪敊");
}
}
閫氳繃璋冭瘯spring婧愮爜
......
Getting transaction for [A.鏂規(guī)硶] .....
......
Creating nested transaction with name [B.savePoint鏂規(guī)硶]........
......
Participating in existing transaction
Getting transaction for [C.鏂規(guī)硶]
........
Participating transaction failed - marking existing transaction as rollback-only
//姝ゆ椂錛屽凡鎶婁富浜嬪姟鏍囪鎴愪簡rollback-only
鎵浠ワ紝褰撳湪a.鏂規(guī)硶瀹屾垚鏃舵彁浜や簨鍔℃椂浼?xì)鎶ransaction has been rolled back because it has been marked as rollback閿欒銆?/p>
璁ょ湡鐨勬?zhèn)ㄥ彲鑳戒細(xì)鍙戠帋图屽?org.springframework.transaction.support.AbstractPlatformTransactionManager 涓湁涓彨
isGlobalRollbackOnParticipationFailure鐨勫弬鏁幫紝榛樿鏄痶rue.
婧愮爜涓鏄庯細(xì)
Switch this to "false" to let the transaction originator make the rollback decision. If a participating transaction fails with an exception, the caller can still decide to continue with a different path within the transaction. However, note that this will only work as long as all participating resources are capable of continuing towards a transaction commit even after a data access failure: This is generally not the case for a Hibernate Session, for example; neither is it for a sequence of JDBC insert/update/delete operations.
澶ф剰鏄細(xì)濡傛灉isGlobalRollbackOnParticipationFailure涓篺alse,鍒欎細(xì)璁╀富浜嬪姟鍐沖畾鍥炴粴錛屽鏋滃綋閬囧埌exception鍔犲叆浜嬪姟澶辮觸鏃訛紝璋冪敤鑰呰兘緇х畫鍦ㄤ簨鍔″唴鍐沖畾鏄洖婊氳繕鏄戶緇傜劧鑰岋紝瑕佹敞鎰忔槸閭f牱鍋氫粎浠呴傜敤浜庡湪鏁版嵁璁塊棶澶辮觸鐨勬儏鍐典笅涓斿彧瑕佹墍鏈夋搷浣滀簨鍔¤兘鎻愪氦銆?/p>
鍒濇瑙e喅鏂規(guī)錛?/p>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> <property name="globalRollbackOnParticipationFailure" value="false" /> <!--鎸囧畾姝ゅ弬鏁頒負(fù)false-->
</bean>
緇忔祴璇曪紝姝ら棶棰樻殏鏃跺緱鍒拌В鍐籌紝涓嶇煡閬撲細(xì)涓嶄細(xì)寮曡搗鍏跺畠闂錛岃嚦灝戠洰鍓嶈繕娌℃湁鍙戠幇鍏跺畠寮傚父銆傛?zhèn)ㄨ嫢閫氳繃姝ゆ柟妗堣В鍐充箣鍚庡嚭鐜頒簡鏂扮殑闂璇風(fēng)暀淇″洖澶嶏紝鎴戜滑涓璧蜂氦嫻侊紝闈炲父鎰熻阿錛?/p>