{"id":14959449,"url":"https://github.com/jillesvangurp/spring-depend","last_synced_at":"2025-05-02T12:31:06.925Z","repository":{"id":17187705,"uuid":"81315215","full_name":"jillesvangurp/spring-depend","owner":"jillesvangurp","description":"Tool for getting a spring bean dependency graph","archived":false,"fork":false,"pushed_at":"2024-10-18T21:40:20.000Z","size":49,"stargazers_count":41,"open_issues_count":1,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-07T01:52:19.750Z","etag":null,"topics":["dependency-graph","dependency-injection","java-8","neo4j","spring"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jillesvangurp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-08T10:01:57.000Z","updated_at":"2025-02-22T14:38:49.000Z","dependencies_parsed_at":"2024-11-15T22:31:31.228Z","dependency_job_id":"7c05dd40-31af-4adc-ac91-8c8cf5550c05","html_url":"https://github.com/jillesvangurp/spring-depend","commit_stats":{"total_commits":27,"total_committers":4,"mean_commits":6.75,"dds":"0.14814814814814814","last_synced_commit":"ea9f0ffae30c4f1a94a27c9da41ecb6024e21325"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jillesvangurp%2Fspring-depend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jillesvangurp%2Fspring-depend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jillesvangurp%2Fspring-depend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jillesvangurp%2Fspring-depend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jillesvangurp","download_url":"https://codeload.github.com/jillesvangurp/spring-depend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252038113,"owners_count":21684626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-graph","dependency-injection","java-8","neo4j","spring"],"created_at":"2024-09-24T13:19:45.616Z","updated_at":"2025-05-02T12:31:06.578Z","avatar_url":"https://github.com/jillesvangurp.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring-depend\n\nTool for analyzing spring dependencies \u0026 exporting your dependencies to neo4j. Similar tools exist but they seem to be bundled with complicated IDE plugins or other stuff I don't really need/use. This makes standalone usage a bit hard. This is a standalone thing. All you need to use this is a spring application context. \n\nTo use: \n - Add the dependency to spring-depend to your existing spring project\n - Get a reference to your application context in one of the several ways that spring allows you to do this. Any instance of spring's `GenericApplicationContext` or one of the sub classes should work\n - Do something like this:\n```\nSpringDependencyAnalyzer analyzer = new SpringDependencyAnalyzer(context);\nanalyzer.printReport();\nSystem.out.println(analyzer.beanGraphCypher()) // copy paste in neo4j console \u0026 enjoy!\n```\n\nFeatures:\n  - `Map\u003cString, Set\u003cString\u003e\u003e getBeanDependencies()` returns a map of all the beans in your context and their dependencies. Needing lots of things is a sign of low coherence and high coupling.\n  - `Map\u003cString, Set\u003cString\u003e\u003e getReverseBeanDependencies()` returns reverse dependencies. Being used a lot is a good thing; it indicates usefulness. Things that are rarely used might not need to be beans on the other hand.\n  - `SimpleGraph\u003cString\u003e getBeanGraph()` a graph of the dependencies. (TODO: technically this is a reverse dependency graph that is generated from both the dependency and reverse dependency map. I need to add the ability to invert it.)\n  - `SimpleGraph\u003cClass\u003c?\u003e\u003e getConfigurationGraph(Class\u003c?\u003e configurationClass)` return a graph of your `@Configuration` classes by following the imports from the specified root class.\n  - `Map\u003cInteger, Set\u003cClass\u003c?\u003e\u003e\u003e getConfigurationLayers(Class\u003c?\u003e configurationClass)` returns a tree map with the configuration classes ordered in layers by their dependencies on each other. The more layers you need, the more complex your spring dependencies are. Consider refactoring them to have less interdependencies. Untangling the the most coupled beans will likely clear this up.  \n  - `String configurationGraphCypher(Class\u003c?\u003e)` returns neo4j cypher for your Spring configuration import dependencies in neo4j\n  - `String beanGraphCypher()` returns neo4j cypher for creating your spring bean dependency graph in neo4j\n  - `String getCircularDependencyStatisticJson()` return json report with all circular bean dependency. For example:\n       ```\n        {\n            \"createDate\": \"Feb 28, 2020 11:04:40 AM\",\n            \"allBeanCircularDependencyCount\": 19,\n            \"dependencyMap\": {\n              \"bean7\": {\n                \"injectedBeanCount\": 1,\n                \"injectedBeanNames\": [\n                  \"bean6\"\n                ],\n                \"circularDependencyCount\": 5,\n                \"circularDependencyDescriptions\": [\n                  \"bean7-bean6-bean7\",\n                  \"bean7-bean6-bean5-bean4-bean1-bean7\",\n                  \"bean7-bean6-bean5-bean4-bean3-bean7\",\n                  \"bean7-bean6-bean5-bean7\",\n                  \"bean7-bean6-bean5-bean4-bean7\"\n                ]\n              },\n              \"bean6\": {\n                \"injectedBeanCount\": 2,\n                \"injectedBeanNames\": [\n                  \"bean5\",\n                  \"bean7\"\n                ],\n                \"circularDependencyCount\": 4,\n                \"circularDependencyDescriptions\": [\n                  \"bean6-bean5-bean4-bean7-bean6\",\n                  \"bean6-bean5-bean4-bean1-bean3-bean7-bean6\",\n                  \"bean6-bean5-bean4-bean1-bean7-bean6\",\n                  \"bean6-bean5-bean7-bean6\"\n                ]\n              }\n        }\n       ``` \n\n# Future work\nWhen time allows, I might work on these topics a bit. Pull requests are welcome of course.\n\n  - Better graph implementation than the rather limited `SimpleGraph` currently included. This was a quick and dirty job but it seems good enough. \n  - Fix the bean graph to not be a reverse dependency graph.\n  - Simple metrics for coherence and coupling.\n  - Test framework support so you can assert constraints on your dependencies and related metrics from a simple unit test.\n\n# Get it from Maven Central\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.jillesvangurp\u003c/groupId\u003e\n    \u003cartifactId\u003espring-depend\u003c/artifactId\u003e\n    \u003c!-- check maven central for latest, Readme's get out of date so easily ... --\u003e\n    \u003cversion\u003e0.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nNote. the spring dependency in the pom is optional. This is so you can specify which spring version you use and avoid nasty conflicts. Anything recent (4.x and up) should pretty much work with this and perhaps older versions too. \n\n# License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjillesvangurp%2Fspring-depend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjillesvangurp%2Fspring-depend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjillesvangurp%2Fspring-depend/lists"}