{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/12941","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/12941/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/12941/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/12941/events","html_url":"https://github.com/spring-projects/spring-boot/issues/12941","id":316570059,"number":12941,"title":"Best practice for Auto-Configuration loading based on Spring Boot version","user":{"login":"ruifigueira","id":1374559,"avatar_url":"https://avatars2.githubusercontent.com/u/1374559?v=4","gravatar_id":"","url":"https://api.github.com/users/ruifigueira","html_url":"https://github.com/ruifigueira","followers_url":"https://api.github.com/users/ruifigueira/followers","following_url":"https://api.github.com/users/ruifigueira/following{/other_user}","gists_url":"https://api.github.com/users/ruifigueira/gists{/gist_id}","starred_url":"https://api.github.com/users/ruifigueira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruifigueira/subscriptions","organizations_url":"https://api.github.com/users/ruifigueira/orgs","repos_url":"https://api.github.com/users/ruifigueira/repos","events_url":"https://api.github.com/users/ruifigueira/events{/privacy}","received_events_url":"https://api.github.com/users/ruifigueira/received_events","type":"User","site_admin":false},"labels":[{"id":293438798,"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/status:%20waiting-for-triage","name":"status: waiting-for-triage","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-22T11:09:02Z","updated_at":"2018-04-22T11:25:47Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"As part of an effort to support both Spring Boot 1.5 and 2.0 for Togglz (https://github.com/togglz/togglz/pull/271) I have two equivalent `AutoConfiguration` classes that are Spring Boot version dependent, and so I'm using `@ConditionalOnClass` annotations with Spring boot version specific classes as parameter to only load the right `AutoConfiguration` class.\r\n\r\nI would like to know if there is a best practice for this, or if my approach is acceptable.\r\n\r\nI'm aware that supporting different Spring Boot versions is actually being contemplated (#12733), so it would be great if documentation also include guidelines on how to achieve that.\r\n\r\n<!--\r\nThanks for raising a Spring Boot issue. What sort of issue are you raising?\r\n\r\nQuestion\r\n\r\nPlease ask questions about how to use something, or to understand why something isn't\r\nworking as you expect it to, on Stack Overflow using the spring-boot tag.\r\n\r\nBug report\r\n\r\nPlease provide details of the problem, including the version of Spring Boot that you\r\nare using. If possible, please provide a test case or sample application that reproduces\r\nthe problem. This makes it much easier for us to diagnose the problem and to verify that\r\nwe have fixed it.\r\n\r\nEnhancement\r\n\r\nPlease start by describing the problem that you are trying to solve. There may already\r\nbe a solution, or there may be a way to solve it that you hadn't considered.\r\n-->"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/383374532","html_url":"https://github.com/spring-projects/spring-boot/issues/12941#issuecomment-383374532","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/12941","id":383374532,"user":{"login":"ruifigueira","id":1374559,"avatar_url":"https://avatars2.githubusercontent.com/u/1374559?v=4","gravatar_id":"","url":"https://api.github.com/users/ruifigueira","html_url":"https://github.com/ruifigueira","followers_url":"https://api.github.com/users/ruifigueira/followers","following_url":"https://api.github.com/users/ruifigueira/following{/other_user}","gists_url":"https://api.github.com/users/ruifigueira/gists{/gist_id}","starred_url":"https://api.github.com/users/ruifigueira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruifigueira/subscriptions","organizations_url":"https://api.github.com/users/ruifigueira/orgs","repos_url":"https://api.github.com/users/ruifigueira/repos","events_url":"https://api.github.com/users/ruifigueira/events{/privacy}","received_events_url":"https://api.github.com/users/ruifigueira/received_events","type":"User","site_admin":false},"created_at":"2018-04-22T11:25:47Z","updated_at":"2018-04-22T11:25:47Z","author_association":"CONTRIBUTOR","body":"If the `@ConditionalOnClass` with Spring boot version specific classes as parameter is acceptable, probably it would be better to have a specific `@Conditional` annotation that would use the `@ConditionalOnClass` as a meta-annotation, similar to the the `@ConditionalOnEnabledEndpoint`.\r\n\r\nFor instance:\r\n\r\n```java\r\n// Endpoint annotation only exists since Spring Boot 2\r\nimport org.springframework.boot.actuate.endpoint.annotation.Endpoint;\r\n\r\n@Retention(RetentionPolicy.RUNTIME)\r\n@Target(ElementType.METHOD)\r\n@Documented\r\n@ConditionalOnClass(Endpoint.class)\r\npublic @interface ConditionalOnSpringBoot2 {\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"ruifigueira"}}