{"id":26595,"date":"2018-04-13T11:54:00","date_gmt":"2018-04-13T11:54:00","guid":{"rendered":"https:\/\/blog.jetbrains.com\/idea\/?p=17502"},"modified":"2018-06-13T16:01:26","modified_gmt":"2018-06-13T16:01:26","slug":"spring-and-spring-boot-in-intellij-idea-2018-1","status":"publish","type":"idea","link":"https:\/\/blog.jetbrains.com\/zh-hans\/idea\/2018\/04\/spring-and-spring-boot-in-intellij-idea-2018-1","title":{"rendered":"Spring and Spring Boot in IntelliJ IDEA 2018.1"},"content":{"rendered":"<p>IntelliJ IDEA 2018.1 comes, as usual, with a lot of features to support developers who use Spring and Spring Boot. We also now have an <a href=\"http:\/\/www.jetbrains.org\/intellij\/sdk\/docs\/reference_guide\/frameworks_and_external_apis\/spring_api.html#spring-boot\" target=\"_blank\" rel=\"noopener\">OpenAPI for Spring Boot<\/a>, which allows\u00a0third party plugins to re-use, integrate with or extend the existing Spring Boot support in IntelliJ IDEA.<\/p>\n<p>IntelliJ IDEA 2018.1 fully supports <a href=\"https:\/\/github.com\/spring-projects\/spring-boot\/wiki\/Spring-Boot-2.0-Release-Notes\" target=\"_blank\" rel=\"noopener\">Spring Boot 2.0<\/a>, and the following features will work for Spring Boot 1.x as well as Spring Boot 2.0.<\/p>\n<p>Spring Boot web applications are now easier to test and debug.\u00a0 Methods annotated with <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/javadoc-api\/org\/springframework\/web\/bind\/annotation\/RequestMapping.html\" target=\"_blank\" rel=\"noopener\">@RequestMapping<\/a>\u00a0or <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/javadoc-api\/org\/springframework\/web\/bind\/annotation\/GetMapping.html\" target=\"_blank\" rel=\"noopener\">@GetMapping<\/a>\u00a0now have gutter icons that\u00a0let you use the new\u00a0<a href=\"https:\/\/www.jetbrains.com\/help\/idea\/rest-client-tool-window.html\" target=\"_blank\" rel=\"noopener\">REST client<\/a>\u00a0to\u00a0make an HTTP request to the given URI.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-01-request-edit.png\" rel=\"attachment wp-att-17511\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17511\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-01-request-edit.png\" alt=\"01-request-edit\" width=\"950\" height=\"259\" \/><\/a><\/p>\n<p><!--more-->In order to enable this, you must have a dependency upon the <a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/htmlsingle\/#production-ready\" target=\"_blank\" rel=\"noopener\">Spring Boot Actuator<\/a> library, and the application also needs to be running:<\/p>\n<blockquote class=\"twitter-tweet\" data-lang=\"en\">\n<p dir=\"ltr\" lang=\"en\">Rest client integration for Spring Boot <a href=\"https:\/\/twitter.com\/springboot?ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">@springboot<\/a> in <a href=\"https:\/\/twitter.com\/hashtag\/IntelliJ?src=hash&amp;ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">#IntelliJ<\/a> IDEA 2018.1 <a href=\"https:\/\/t.co\/fNSS0gPZic\" target=\"_blank\">pic.twitter.com\/fNSS0gPZic<\/a><\/p>\n<p>\u2014 Anton Arhipov (@antonarhipov) <a href=\"https:\/\/twitter.com\/antonarhipov\/status\/978919446671654912?ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">March 28, 2018<\/a><\/p><\/blockquote>\n<p><script src=\"https:\/\/platform.twitter.com\/widgets.js\" async=\"\" charset=\"utf-8\"><\/script><\/p>\n<p>To test a POST request,\u00a0select\u00a0&#8220;Open in HTTP Request Editor&#8221;, which opens a new scratch file with the appropriate URL.\u00a0\u00a0Changing the values in this scratch file lets you\u00a0try out the request with different values. You can see not only the output, but the header values, response code, time taken and\u00a0other useful\u00a0 information about the\u00a0response.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17508\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-02-edit-request-prev.png\" alt=\"Edit HTTP Request\" width=\"1990\" height=\"604\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-02-edit-request.gif\" \/><\/p>\n<p>Methods annotated with @GetMapping also give the option to open this URL in the browser.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-03-open-in-browser.png\" rel=\"attachment wp-att-17509\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17509\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-03-open-in-browser.png\" alt=\"03-open-in-browser\" width=\"950\" height=\"226\" \/><\/a><\/p>\n<p>Check out the <a href=\"https:\/\/www.jetbrains.com\/help\/idea\/spring-boot.html#access-http-request-mappings-from-the-editor\" target=\"_blank\" rel=\"noopener\">documentation for this feature<\/a>.<\/p>\n<p>Navigating through Bean declarations is now easier in IntelliJ IDEA 2018.1.\u00a0 Previously,\u00a0the IDE showed all the beans in the <a href=\"https:\/\/blog.jetbrains.com\/idea\/2017\/08\/intellij-idea-2017-2-1-junit-5-rc2-spring-run-dashboard-and-its-faster\/\">Run Dashboard<\/a>.\u00a0\u00a0This functionality has now been extended so you can\u00a0navigate through\u00a0the beans from within the editor &#8211; there are new gutter icons that show the beans\u00a0that are relevant for the current class.\u00a0 Where appropriate, you can see where this class is injected and which beans it depends upon.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17513\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-04-beans-prev.png.gif\" alt=\"Navigate through Beans\" width=\"1990\" height=\"604\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-04-beans.gif\" \/><\/p>\n<p>This feature also needs you to have the application running in order to work.\u00a0 Also, it only shows the beans that are registered in the running context.<\/p>\n<p>IntelliJ IDEA 2018.1 has added the ability to rename caches.\u00a0 From <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/javadoc-api\/org\/springframework\/cache\/annotation\/package-summary.html\" target=\"_blank\" rel=\"noopener\">cache annotations<\/a> like\u00a0@CacheEvict,\u00a0@CachePut and @Cacheable, it&#8217;s possible to rename the cache and IntelliJ IDEA will make sure all\u00a0uses of that cache are updated to the new name.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17584\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/04\/idea-05-rename-cache-kt-prev.png\" alt=\"Rename Cache\" width=\"1990\" height=\"604\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/04\/idea-05-rename-cache-kt.gif\" \/><\/p>\n<p>As you can see from the example above, this works not only with Java, but also Kotlin.\u00a0 Similarly, you&#8217;ll get <a href=\"https:\/\/docs.spring.io\/spring\/docs\/5.0.4.RELEASE\/spring-framework-reference\/core.html#expressions\" target=\"_blank\" rel=\"noopener\">SpEL<\/a> code completion now for @Cacheable, @CacheEvict and @EventListener annotations\u00a0when you&#8217;re\u00a0using Kotlin.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17587\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/04\/idea-08-kotlin-spel-prev.png\" alt=\"SpEL Code Completion in Kotlin\" width=\"1990\" height=\"604\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/04\/idea-08-kotlin-spel.gif\" \/><\/p>\n<p>A lot of work has gone into improving support for configuration files and improving and expanding auto configuration. You&#8217;ll notice better performance, better code completion and suggestions,\u00a0better organisation of suggestions, and, of course, bug fixes too.<\/p>\n<p>Another area that benefits from improved performance is diagrams.\u00a0 Large graphs and Spring diagrams in IntelliJ IDEA 2018.1 perform faster and use less memory.<\/p>\n<p><strong>Spring Boot Developer Tools<\/strong><\/p>\n<p><a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/using-boot-devtools.html\" target=\"_blank\" rel=\"noopener\">Spring Boot&#8217;s Developer Tools<\/a>\u00a0help\u00a0developers\u00a0get more rapid feedback and work more efficiently.\u00a0 IntelliJ IDEA 2018.1\u00a0has introduced some settings to reduce the code\/deploy\/test cycle when using Devtools.<\/p>\n<p>If you&#8217;re running an application with Devtools enabled,\u00a0there&#8217;s a new &#8220;Update&#8221; action which can trigger an application restart.\u00a0 You can configure what happens when you perform the update in\u00a0the Run Configuration:<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-07-on-update.png\" rel=\"attachment wp-att-17507\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17507\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-07-on-update.png\" alt=\"07-on-update\" width=\"1255\" height=\"950\" \/><\/a><\/p>\n<p>The following policies are available:<\/p>\n<ul>\n<li><em>Update resources<\/em>: Update action performs resource update.<\/li>\n<li><em>Update classes and resources:<\/em>\u00a0Update action performs build.<\/li>\n<li><em>Update trigger file:<\/em>\u00a0Update action triggers an application restart by touching trigger file.<\/li>\n<li><em>Hot swap classes and update trigger file if failed:<\/em>\u00a0Update action performs build and hot swap. If hot swap is failed an application restart\u00a0will be triggered by touching trigger file.<\/li>\n<\/ul>\n<p>If you select either of the last two options, IntelliJ IDEA <a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/using-boot-devtools.html#using-boot-devtools-restart-triggerfile\" target=\"_blank\" rel=\"noopener\">sets a trigger file<\/a> when you start the application (it&#8217;s the equivalent of adding the VM option <code>-Dspring.devtools.restart.trigger-file=.restartTriggerFile<\/code>)<\/p>\n<p>In addition to this,\u00a0IntelliJ IDEA 2018.1 also makes it easier to work with\u00a0static assets and templates when using Devtools.\u00a0 In the same Run Configuration dialog,\u00a0you can define what happens on On frame deactivation (e.g. when the editor loses focus). Selecting &#8220;Update resources&#8221; will automatically update\u00a0static assets and templates.<\/p>\n<p><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-06-update-resources.png\" rel=\"attachment wp-att-17512\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-17512\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2018\/03\/idea-06-update-resources.png\" alt=\"06-update-resources\" width=\"1255\" height=\"950\" \/><\/a><\/p>\n<p><strong>Spring Security 5.0 &amp;\u00a0Spring Integration 5.0<\/strong><\/p>\n<p><a href=\"https:\/\/docs.spring.io\/spring-security\/site\/docs\/5.0.4.BUILD-SNAPSHOT\/reference\/htmlsingle\/#new\" target=\"_blank\" rel=\"noopener\">Spring Security 5.0<\/a>\u00a0introduced support for Spring Framework 5, but also a number of <a href=\"https:\/\/docs.spring.io\/spring-security\/site\/docs\/5.0.4.BUILD-SNAPSHOT\/reference\/htmlsingle\/#new\" target=\"_blank\" rel=\"noopener\">new features and bug fixes<\/a>. It is completely supported in IntelliJ IDEA 2018.1.<\/p>\n<p><a href=\"https:\/\/docs.spring.io\/spring-integration\/reference\/html\/whats-new.html\" target=\"_blank\" rel=\"noopener\">Spring Integration 5.0<\/a>\u00a0also\u00a0contains new features, improvements and bug fixes.\u00a0 IntelliJ IDEA 2018.1 fully supports XML configuration for Spring integration, including all the new XML schemas introduced in this release.<\/p>\n<p><strong>Summary<\/strong><\/p>\n<p>IntelliJ IDEA 2018.1 has full support for the latest version of the Spring Framework and Spring Boot, improved performance when using these, and a new API to help third party developers provide tools for working with Spring Boot.<\/p>\n<p>More information about all the\u00a0new features and bug fixes can be <a href=\"https:\/\/youtrack.jetbrains.com\/issues\/IDEA?q=%23Spring%20Fix%20versions:%20%7B2018.1%20(181.4203.550)%7D%20Fix%20versions:%20%7B2018.1.1%20(181.4445.78)%7D%20\" target=\"_blank\" rel=\"noopener\">found in YouTrack<\/a>.<\/p>\n","protected":false},"author":360,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","categories":[907],"tags":[685,276,3211,3064],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/idea\/26595"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/idea"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/types\/idea"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/users\/360"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/comments?post=26595"}],"version-history":[{"count":0,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/idea\/26595\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media?parent=26595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/categories?post=26595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/tags?post=26595"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/cross-post-tag?post=26595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}