|
2 | 2 | title: Custom Setup |
3 | 3 | --- |
4 | 4 |
|
5 | | -TODO |
| 5 | +The standard setup using the Spring Boot starter works for most users, but if you need more control over the configuration, you can use a custom setup. |
| 6 | +To create a custom setup, follow these steps: |
| 7 | + |
| 8 | +You can add only the dependencies you need to your `pom.xml`. For example, if you only need the domain-jpa module: |
| 9 | + |
| 10 | +```xml |
| 11 | +<dependency> |
| 12 | + <groupId>tools.dynamia</groupId> |
| 13 | + <artifactId>tools.dynamia.domain-jpa</artifactId> |
| 14 | + <version>LATEST_VERSION</version> |
| 15 | +</dependency> |
| 16 | +``` |
| 17 | + |
| 18 | +Suppose you have a multi-module project with the following structure: |
| 19 | + |
| 20 | +``` |
| 21 | +my-app |
| 22 | + ├── core |
| 23 | + ├── ui |
| 24 | + ├── boot |
| 25 | + └── pom.xml |
| 26 | +``` |
| 27 | + |
| 28 | +The `core` module could contain only domain-related dependencies: |
| 29 | + |
| 30 | +```xml |
| 31 | +<dependency> |
| 32 | + <groupId>tools.dynamia</groupId> |
| 33 | + <artifactId>tools.dynamia.domain-jpa</artifactId> |
| 34 | + <version>LATEST_VERSION</version> |
| 35 | +</dependency> |
| 36 | + |
| 37 | +<dependency> |
| 38 | + <groupId>tools.dynamia</groupId> |
| 39 | + <artifactId>tools.dynamia.integration</artifactId> |
| 40 | + <version>LATEST_VERSION</version> |
| 41 | +</dependency> |
| 42 | +``` |
| 43 | + |
| 44 | +The `ui` module could contain only UI-related dependencies: |
| 45 | + |
| 46 | +```xml |
| 47 | +<dependency> |
| 48 | + <groupId>tools.dynamia</groupId> |
| 49 | + <artifactId>tools.dynamia.crud</artifactId> |
| 50 | + <version>LATEST_VERSION</version> |
| 51 | +</dependency> |
| 52 | +``` |
| 53 | + |
| 54 | +And the `boot` module could contain the Spring Boot-related dependencies: |
| 55 | + |
| 56 | +```xml |
| 57 | +<dependency> |
| 58 | + <groupId>tools.dynamia</groupId> |
| 59 | + <artifactId>tools.dynamia.app</artifactId> |
| 60 | + <version>LATEST_VERSION</version> |
| 61 | +</dependency> |
| 62 | +``` |
| 63 | + |
| 64 | +Finally, in your main application class, you need to enable Dynamia by adding the `@EnableDynamiaTools` annotation: |
| 65 | + |
| 66 | +```java |
| 67 | +import org.springframework.boot.SpringApplication; |
| 68 | +import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 69 | +import tools.dynamia.app.EnableDynamiaTools; |
| 70 | + |
| 71 | +@SpringBootApplication |
| 72 | +@EnableDynamiaTools // <- this is all you need |
| 73 | +public class MyApplication { |
| 74 | + |
| 75 | + public static void main(String[] args) { |
| 76 | + SpringApplication.run(MyApplication.class, args); |
| 77 | + } |
| 78 | + |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +You can provide custom configuration in your `application.yml` or `application.properties` file: |
| 83 | + |
| 84 | +```yaml |
| 85 | +spring: |
| 86 | + dynamia: |
| 87 | + app: |
| 88 | + base-package: com.mycompany.myapp |
| 89 | + name: My Application |
| 90 | + version: @project.version@ |
| 91 | +``` |
| 92 | +
|
| 93 | +### Additional Tips |
| 94 | +
|
| 95 | +- Make sure to use the correct version for each dependency. |
| 96 | +- You can further customize your modules by adding or removing dependencies as needed. |
| 97 | +- For advanced configuration, refer to the official Dynamia documentation. |
| 98 | +- DynamiaTools is a typical Spring Boot application, so you can use all Spring Boot features and configurations. |
0 commit comments