{"id":2182,"date":"2017-08-05T11:22:30","date_gmt":"2017-08-05T11:22:30","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=2182"},"modified":"2018-10-10T17:15:56","modified_gmt":"2018-10-10T17:15:56","slug":"using-java-eejsr-330-annotations-like-inject-in-spring","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=2182","title":{"rendered":"Using Java EE\/JSR-330 annotations like @Inject in Spring"},"content":{"rendered":"<p>I came across a Spring Boot app which clearly used Spring for its IOC (@Configuration classes defining Spring Beans with&#160; @Bean)<\/p>\n<p>The app also used @Inject\/javax.inject which initially led me to think it was using CDI\/Weld, i.e. was using 2 IOC frameworks.<\/p>\n<p>However, Spring also supports the basic Java EE annotations via JSR-330. JS-299 is the full CDI\/Weld spec, but there was robust debate about Spring taking on board the full JSR-330 spec, and in the end they just went for a small subset which became JSR-299.<\/p>\n<p>This includes among other things @Inject, so this can be used as a synonym for @Autowired.<\/p>\n<p>Adam Bien describes the difference between JSR-299 and JSR-330 very well in <a href=\"http:\/\/www.adam-bien.com\/roller\/abien\/entry\/what_is_the_relation_between\">this post here<\/a>.<\/p>\n<p><a href=\"https:\/\/blogs.sourceallies.com\/2011\/08\/spring-injection-with-resource-and-autowired\/#more-2350\">This blog post<\/a> by David Kessler describes and investigates the use of both in code very well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I came across a Spring Boot app which clearly used Spring for its IOC (@Configuration classes defining Spring Beans with&#160; @Bean) The app also used @Inject\/javax.inject which initially led me to think it was using CDI\/Weld, i.e. was using 2 IOC frameworks. However, Spring also supports the basic Java EE annotations via JSR-330. JS-299 is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[150,95],"tags":[16],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2182"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2182"}],"version-history":[{"count":1,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2182\/revisions"}],"predecessor-version":[{"id":2183,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2182\/revisions\/2183"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}