ΪʲôҪѧϰ Spring Boot£¿
2019-02-27 11:52:48À´Ô´£º²©¿ÍÔ° ÔĶÁ ()
ÎÒÃÇÖªµÀ£¬´Ó 2002 Ä꿪ʼ£¬Spring Ò»Ö±ÔÚ·ÉËٵķ¢Õ¹£¬Èç½ñÒѾ³ÉΪÁËÔÚJava EE£¨Java Enterprise Edition£©¿ª·¢ÖÐÕæÕýÒâÒåÉϵıê×¼£¬µ«ÊÇËæ׿¼ÊõµÄ·¢Õ¹£¬Java EEʹÓà Spring Öð½¥±äµÃ±¿ÖØÆðÀ´£¬´óÁ¿µÄ XML Îļþ´æÔÚÓÚÏîÄ¿Ö®ÖС£·±ËöµÄÅäÖã¬ÕûºÏµÚÈý·½¿ò¼ÜµÄÅäÖÃÎÊÌ⣬µ¼ÖÂÁË¿ª·¢ºÍ²¿ÊðЧÂʵĽµµÍ¡£
2012 Äê 10 Ô£¬Mike Youngstrom ÔÚ Spring jira Öд´½¨ÁËÒ»¸ö¹¦ÄÜÇëÇó£¬ÒªÇóÔÚ Spring ¿ò¼ÜÖÐÖ§³ÖÎÞÈÝÆ÷ Web Ó¦ÓóÌÐòÌåϵ½á¹¹¡£Ëû̸µ½ÁËÔÚÖ÷ÈÝÆ÷Òýµ¼ spring ÈÝÆ÷ÄÚÅäÖà Web ÈÝÆ÷·þÎñ¡£ÕâÊÇ jira ÇëÇóµÄժ¼£º
ÎÒÈÏΪ Spring µÄ Web Ó¦ÓÃÌåϵ½á¹¹¿ÉÒÔ´ó´ó¼ò»¯£¬Èç¹ûËüÌṩÁË´ÓÉϵ½ÏÂÀûÓà Spring ×é¼þºÍÅäÖÃÄ£Ð͵Ť¾ßºÍ²Î¿¼Ìåϵ½á¹¹¡£ÔÚ¼òµ¥µÄ
main()
·½·¨Òýµ¼µÄ Spring ÈÝÆ÷ÄÚǶÈëºÍͳһÕâЩ³£ÓÃWeb ÈÝÆ÷·þÎñµÄÅäÖá£
ÕâÒ»ÒªÇó´ÙʹÁË 2013 Äê³õ¿ªÊ¼µÄ Spring Boot ÏîÄ¿µÄÑз¢£¬µ½½ñÌ죬Spring Boot µÄ°æ±¾ÒѾµ½ÁË 2.0.3 RELEASE¡£Spring Boot ²¢²»ÊÇÓÃÀ´Ìæ´ú Spring µÄ½â¾ö·½°¸£¬¶øÊÇºÍ Spring ¿ò¼Ü½ôÃܽáºÏÓÃÓÚÌáÉý Spring ¿ª·¢ÕßÌåÑéµÄ¹¤¾ß¡£Í¬Ê±Ëü¼¯³ÉÁË´óÁ¿³£ÓõĵÚÈý·½¿âÅäÖã¬Spring BootÓ¦ÓÃÖÐÕâЩµÚÈý·½¿â¼¸ºõ¿ÉÒÔÊÇÁãÅäÖõĿªÏä¼´Óã¨out-of-the-box£©£¬´ó²¿·ÖµÄ Spring Boot Ó¦Óö¼Ö»ÐèÒª·Ç³£ÉÙÁ¿µÄÅäÖôúÂ루»ùÓÚ Java µÄÅäÖã©£¬¿ª·¢ÕßÄܹ»¸ü¼ÓרעÓÚÒµÎñÂß¼¡£
ΪʲôѧϰSpring Boot
´ÓSpring¹Ù·½À´¿´
ÎÒÃÇ´ò¿ª Spring µÄ¹Ù·½ÍøÕ¾£¬¿ÉÒÔ¿´µ½ÏÂͼ£º
ÎÒÃÇ¿ÉÒÔ¿´µ½Í¼Öйٷ½¶Ô Spring Boot µÄ¶¨Î»£ºBuild Anything£¬ BuildÈκζ«Î÷¡£Spring BootÖ¼ÔÚ¾¡¿ÉÄÜ¿ìµØÆô¶¯ºÍÔËÐУ¬²¢ÇÒÖ»Ðè×îÉÙµÄ Spring Ç°ÆÚÅäÖᣠͬʱÎÒÃÇÒ²À´¿´Ò»Ï¹ٷ½¶ÔºóÃæÁ½¸öµÄ¶¨Î»£º
SpringCloud£ºCoordinate Anything£¬Ðµ÷ÈκÎÊÂÇ飻
SpringCloud Data Flow£ºConnect everything£¬Á¬½ÓÈκζ«Î÷¡£
×ÐϸƷζһÏ£¬Spring ¹ÙÍø¶Ô Spring Boot¡¢SpringCloud ºÍ SpringCloud Data FlowÈýÕ߶¨Î»µÄ´ë´Ç·Ç³£ÓÐζµÀ£¬Í¬Ê±Ò²¿ÉÒÔ¿´³ö£¬Spring ¹Ù·½¶ÔÕâÈý¸ö¼¼Êõ·Ç³£ÖØÊÓ£¬ÊÇÏÖÔÚÒÔ¼°½ñºóѧϰµÄÖص㣨SpringCloud Ïà¹Ø´ïÈ˿ογ̽ìʱҲ»áÉÏÏߣ©¡£
´ÓSpring BootµÄÓŵãÀ´¿´
Spring Boot ÓÐÄÄЩÓŵ㣿Ö÷Òª¸øÎÒÃǽâ¾öÁËÄÄЩÎÊÌâÄØ£¿ÎÒÃÇÒÔÏÂͼÀ´ËµÃ÷£º
Á¼ºÃµÄ»ùÒò
Spring Boot ÊÇ°éËæ×Å Spring 4.0 µ®ÉúµÄ£¬´Ó×ÖÃæÀí½â£¬BootÊÇÒýµ¼µÄÒâ˼£¬Òò´Ë Spring Boot Ö¼ÔÚ°ïÖú¿ª·¢Õß¿ìËٴ Spring ¿ò¼Ü¡£Spring Boot ¼Ì³ÐÁËÔÓÐ Spring ¿ò¼ÜµÄÓÅÐã»ùÒò£¬Ê¹ Spring ÔÚʹÓÃÖиü¼Ó·½±ã¿ì½Ý¡£
¼ò»¯±àÂë
¾Ù¸öÀý×Ó£¬±ÈÈçÎÒÃÇÒª´´½¨Ò»¸ö web ÏîÄ¿£¬Ê¹Óà Spring µÄÅóÓѶ¼ÖªµÀ£¬ÔÚʹÓà Spring µÄʱºò£¬ÐèÒªÔÚ pom ÎļþÖÐÌí¼Ó¶à¸öÒÀÀµ£¬¶ø Spring Boot Ôò»á°ïÖú¿ª·¢×Å¿ìËÙÆô¶¯Ò»¸ö web ÈÝÆ÷£¬ÔÚ Spring Boot ÖУ¬ÎÒÃÇÖ»ÐèÒªÔÚ pom ÎļþÖÐÌí¼ÓÈçÏÂÒ»¸ö starter-web ÒÀÀµ¼´¿É¡£
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
ÎÒÃǵã»÷½øÈë¸ÃÒÀÀµºó¿ÉÒÔ¿´µ½£¬Spring Boot Õâ¸ö starter-web ÒѾ°üº¬Á˶à¸öÒÀÀµ£¬°üÀ¨Ö®Ç°ÔÚ Spring ¹¤³ÌÖÐÐèÒªµ¼ÈëµÄÒÀÀµ£¬ÎÒÃÇ¿´Ò»ÏÂÆäÖеÄÒ»²¿·Ö£¬ÈçÏ£º
<!-- .....Ê¡ÂÔÆäËûÒÀÀµ -->
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.0.7.RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.0.7.RELEASE</version> <scope>compile</scope> </dependency>
ÓÉ´Ë¿ÉÒÔ¿´³ö£¬Spring Boot ´ó´ó¼ò»¯ÁËÎÒÃǵıàÂ룬ÎÒÃDz»ÓÃÒ»¸ö¸öµ¼ÈëÒÀÀµ£¬Ö±½ÓÒ»¸öÒÀÀµ¼´¿É¡£
¼ò»¯ÅäÖÃ
Spring ËäȻʹJava EEÇáÁ¿¼¶¿ò¼Ü£¬µ«ÓÉÓÚÆä·±ËöµÄÅäÖã¬Ò»¶È±»ÈËÈÏΪÊÇ“ÅäÖõØÓü”¡£¸÷ÖÖXML¡¢AnnotationÅäÖûáÈÃÈËÑÛ»¨çÔÂÒ£¬¶øÇÒÅäÖöàµÄ»°£¬Èç¹û³ö´íÁËÒ²ºÜÄÑÕÒ³öÔÒò¡£Spring Boot¸ü¶àµÄÊDzÉÓà Java Config µÄ·½Ê½£¬¶Ô Spring ½øÐÐÅäÖ᣾ٸöÀý×Ó£º
ÎÒн¨Ò»¸öÀ࣬µ«ÊÇÎÒ²»Óà @Service
×¢½â£¬Ò²¾ÍÊÇ˵£¬ËüÊǸöÆÕͨµÄÀ࣬ÄÇôÎÒÃÇÈçºÎʹËüÒ²³ÉΪһ¸ö Bean Èà Spring È¥¹ÜÀíÄØ£¿Ö»ÐèÒª@Configuration
ºÍ@Bean
Á½¸ö×¢½â¼´¿É£¬ÈçÏ£º
public class TestService { public String sayHello () { return "Hello Spring Boot!"; } } import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class JavaConfig { @Bean public TestService getTestService() { return new TestService(); } }
@Configuration
±íʾ¸ÃÀàÊǸöÅäÖÃÀ࣬@Bean
±íʾ¸Ã·½·¨·µ»ØÒ»¸ö Bean¡£ÕâÑù¾Í°ÑTestService
×÷Ϊ Bean Èà Spring È¥¹ÜÀíÁË£¬ÔÚÆäËûµØ·½£¬ÎÒÃÇÈç¹ûÐèҪʹÓøà Bean£¬ºÍÔÀ´Ò»Ñù£¬Ö±½ÓʹÓÃ@Resource
×¢½â×¢Èë½øÀ´¼´¿ÉʹÓ㬷dz£·½±ã¡£
@Resource private TestService testService;
ÁíÍ⣬²¿ÊðÅäÖ÷½Ã棬ÔÀ´ Spring Óжà¸ö xml ºÍ propertiesÅäÖã¬ÔÚ Spring Boot ÖÐÖ»ÐèÒª¸ö application.yml¼´¿É¡£
¼ò»¯²¿Êð
ÔÚʹÓà Spring ʱ£¬ÏîÄ¿²¿ÊðʱÐèÒªÎÒÃÇÔÚ·þÎñÆ÷Éϲ¿Êð tomcat£¬È»ºó°ÑÏîÄ¿´ò³É war °üÈÓµ½ tomcatÀÔÚʹÓà Spring Boot ºó£¬ÎÒÃDz»ÐèÒªÔÚ·þÎñÆ÷ÉÏÈ¥²¿Êð tomcat£¬ÒòΪ Spring Boot ÄÚǶÁË tomcat£¬ÎÒÃÇÖ»ÐèÒª½«ÏîÄ¿´ò³É jar °ü£¬Ê¹Óà java -jar xxx.jar
Ò»¼üʽÆô¶¯ÏîÄ¿¡£
ÁíÍ⣬Ҳ½µµÍ¶ÔÔËÐл·¾³µÄ»ù±¾ÒªÇ󣬻·¾³±äÁ¿ÖÐÓÐJDK¼´¿É¡£
¼ò»¯¼à¿Ø
ÎÒÃÇ¿ÉÒÔÒýÈë spring-boot-start-actuator ÒÀÀµ£¬Ö±½ÓʹÓà REST ·½Ê½À´»ñÈ¡½ø³ÌµÄÔËÐÐÆÚÐÔÄܲÎÊý£¬´Ó¶ø´ïµ½¼à¿ØµÄÄ¿µÄ£¬±È½Ï·½±ã¡£µ«ÊÇ Spring Boot Ö»ÊǸö΢¿ò¼Ü£¬Ã»ÓÐÌṩÏàÓ¦µÄ·þÎñ·¢ÏÖÓë×¢²áµÄÅäÌ×¹¦ÄÜ£¬Ã»ÓÐÍâΧ¼à¿Ø¼¯³É·½°¸£¬Ã»ÓÐÍâΧ°²È«¹ÜÀí·½°¸£¬ËùÒÔÔÚ΢·þÎñ¼Ü¹¹ÖУ¬»¹ÐèÒª Spring Cloud À´ÅäºÏÒ»ÆðʹÓá£
´ÓδÀ´·¢Õ¹µÄÇ÷ÊÆÀ´¿´
΢·þÎñÊÇδÀ´·¢Õ¹µÄÇ÷ÊÆ£¬ÏîÄ¿»á´Ó´«Í³¼Ü¹¹ÂýÂýתÏò΢·þÎñ¼Ü¹¹£¬ÒòΪ΢·þÎñ¿ÉÒÔʹ²»Í¬µÄÍŶÓרעÓÚ¸üС·¶Î§µÄ¹¤×÷Ö°Ôð¡¢Ê¹ÓöÀÁ¢µÄ¼¼Êõ¡¢¸ü°²È«¸üƵ·±µØ²¿Ê𡣶ø ¼Ì³ÐÁË Spring µÄÓÅÁ¼ÌØÐÔ£¬Óë Spring Ò»ÂöÏà³Ð£¬¶øÇÒ Ö§³Ö¸÷ÖÖREST API µÄʵÏÖ·½Ê½¡£Spring Boot Ò²Êǹٷ½´óÁ¦ÍƼöµÄ¼¼Êõ£¬¿ÉÒÔ¿´³ö£¬Spring Boot ÊÇδÀ´·¢Õ¹µÄÒ»¸ö´óÇ÷ÊÆ¡£
Ãâ·ÑJava×ÊÁÏÁìÈ¡£¬º¸ÇÁËJava¡¢Redis¡¢MongoDB¡¢MySQL¡¢Zookeeper¡¢Spring Cloud¡¢Dubbo/Kafka¡¢Hadoop¡¢Hbase¡¢FlinkµÈ¸ß²¢·¢·Ö²¼Ê½¡¢´óÊý¾Ý¡¢»úÆ÷ѧϰµÈ¼¼Êõ¡£´«ËÍÃÅ£ºhttps://mp.weixin.qq.com/s/JzddfH-7yNudmkjT0IRL8Q
ÔÎÄÁ´½Ó:https://www.cnblogs.com/yuxiang1/p/10440306.html
ÈçÓÐÒÉÎÊÇëÓëÔ×÷ÕßÁªÏµ
±êÇ©£º
°æȨÉêÃ÷£º±¾Õ¾ÎÄÕ²¿·Ö×ÔÍøÂ磬ÈçÓÐÇÖȨ£¬ÇëÁªÏµ£ºwest999com@outlook.com
Ìرð×¢Ò⣺±¾Õ¾ËùÓÐתÔØÎÄÕÂÑÔÂÛ²»´ú±í±¾Õ¾¹Ûµã£¬±¾Õ¾ËùÌṩµÄÉãÓ°ÕÕƬ£¬²å»£¬Éè¼Æ×÷Æ·£¬ÈçÐèʹÓã¬ÇëÓëÔ×÷ÕßÁªÏµ£¬°æȨ¹éÔ×÷ÕßËùÓÐ
- SpringϵÁÐ.ApplicationContext½Ó¿Ú 2020-06-11
- springboot2ÅäÖÃJavaMelodyÓëspringMVCÅäÖÃJavaMelody 2020-06-11
- ѧϰJava 8 Stream Api (4) - Stream Öն˲Ù×÷Ö® collect 2020-06-11
- javaѧϰ֮µÚÒ»Ìì 2020-06-11
- ¸øÄãÒ»·Ý³¬Ïêϸ Spring Boot ֪ʶÇåµ¥ 2020-06-11
IDC×ÊѶ£º Ö÷»ú×ÊѶ ×¢²á×ÊѶ ÍйÜ×ÊѶ vps×ÊѶ ÍøÕ¾½¨Éè
ÍøÕ¾ÔËÓª£º ½¨Õ¾¾Ñé ²ß»®Ó¯Àû ËÑË÷ÓÅ»¯ ÍøÕ¾Íƹã Ãâ·Ñ×ÊÔ´
ÍøÕ¾ÁªÃË£º ÁªÃËÐÂÎÅ ÁªÃ˽éÉÜ ÁªÃ˵ãÆÀ Íø׬¼¼ÇÉ
ÐÐÒµ×ÊѶ£º ËÑË÷ÒýÇæ ÍøÂçÓÎÏ· µç×ÓÉÌÎñ ¹ã¸æ´«Ã½
ÍøÂç±à³Ì£º Asp.Net±à³Ì Asp±à³Ì Php±à³Ì Xml±à³Ì Access Mssql Mysql ÆäËü
·þÎñÆ÷¼¼Êõ£º Web·þÎñÆ÷ Ftp·þÎñÆ÷ Mail·þÎñÆ÷ Dns·þÎñÆ÷ °²È«·À»¤
Èí¼þ¼¼ÇÉ£º ÆäËüÈí¼þ Word Excel Powerpoint Ghost Vista QQ¿Õ¼ä QQ FlashGet ѸÀ×
ÍøÒ³ÖÆ×÷£º FrontPages Dreamweaver Javascript css photoshop fireworks Flash
³ÌÐòÉè¼Æ£º Java¼¼Êõ C/C++ VB delphi
- Photoshop»æÖÆÁ¢Ìå·ç¸ñµÄ΢Ц±íÇé
- PSÎÄ×ÖÌØЧ½Ì³Ì£ºÖÆ×÷¹«Â·ÉϸöÐÔµÄÍ¿Ñ»
- PhotoshopÉè¼Æ¾í±ßЧ¹ûµÄ±äÐνð¸ÕµçÓ°
- PSÉ«²ÊÐÞ¸´½Ì³Ì£ºÀûÓÃÉ«½×¹¤¾ß¿ìËÙ¸øºì
- PS°ë͸Ã÷ÎïÌå¿Ùͼ£ºÀûÓÃͨµÀÑ¡Çø¹¤¾ß¿Ù
- PSº£±¨Éè¼Æ¼¼Çɽ̳̣ºÑ§Ï°ÖÆ×÷¸öÐԵč
- PSͼƬÌØЧÖÆ×÷½Ì³Ì£ºÑ§Ï°¸øÌúËþͼƬÖÆ
- ѧϰÓÃphotoshop°Ñ»ë×ǵĺ£Ë®ÕÕƬºóÆÚ
- PS¹Å·çÕÕƬ½Ì³Ì£º¸ø¹Å·çÃÀÅ®´òÔì³öÅ®ÏÀ
- PS¸öÐÔÈËÎﺣ±¨ÖÆ×÷£ºÉè¼Æ´´ÒâʱÉеIJ£
- ʲôÈí¼þ¿ÉÒÔµÁȡ΢ÐźÅÃÜÂë,ÔõôµÁ±ð
- ´ÅÁ¦ËÑË÷ÍøÕ¾µ¼º½2020Äê¸üÐÂ
- springcloudѧϰ֮·: (Ò») ×î¼òµ¥µÄ´î
- ´´½¨Gradle¹¤³Ì³öÏÖCould not install
- ³¹µ×Ū¶®¡°PKIX path building failed
- TomcatÆô¶¯±¨´í:org.apache.catalina.L
- spring boot ´íÎó£ºCheck your ViewRes
- »ùÓÚHttpClientµÄаæÕý·½½ÌÎñϵͳģÄâ
- Ö»ÓгÌÐòÔ±²ÅÄÜ¿´¶®µÄ³µÅÆ£¬¶®µÃ×ÔÈ»¶®
- mybatis ×¢½â@Results¡¢@Result¡¢@Resu