Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,26 @@
import java.lang.annotation.Target;

import org.springframework.context.annotation.Import;
import org.sterl.spring.persistent_tasks.config.SpringPersistentTasksConfig;

/**
* Enables the spring persistent task services.
*
* <pre>
* @SpringBootApplication
* @EnableSpringPersistentTasks
* public class MyApp {
* }
* </pre>
* <p>Include corresponding annotation if you use:</p>
* <ul>
* <li>@EntityScan -> {@link EnableSpringPersistentTasksEntityScan}</li>
* <li>@EnableJpaRepositories -> {@link EnableSpringPersistentTasksJpaRepositories}</li>
* <li>@EnableEnversRepositories -> {@link EnableSpringPersistentTasksJpaRepositories}</li>
* </ul>
*
* They break the spring auto configuration.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.sterl.spring.persistent_tasks;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.context.annotation.Import;
import org.sterl.spring.persistent_tasks.config.EnableSpringPersistentTasksEntityScanConfig;

/**
* Annotation to include spring persistent task entities if <code>@EntityScan</code> annotation is used.
*
* <pre>
* @SpringBootApplication
* @EntityScan
* @EnableSpringPersistentTasksEntityScan
* @EnableSpringPersistentTasks
* public class MyApp {
* }
* </pre>
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(EnableSpringPersistentTasksEntityScanConfig.class)
public @interface EnableSpringPersistentTasksEntityScan {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.sterl.spring.persistent_tasks;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.context.annotation.Import;
import org.sterl.spring.persistent_tasks.config.EnableSpringPersistentTasksJpaRepositoriesConfig;

/**
* Annotation to include spring persistent task repositories if <code>@EnableJpaRepositories</code> annotation is used.
*
* <pre>
* @SpringBootApplication
* @EnableJpaRepositories
* @EnableSpringPersistentTasksJpaRepositories
* @EnableSpringPersistentTasks
* public class MyApp {
* }
* </pre>
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(EnableSpringPersistentTasksJpaRepositoriesConfig.class)
public @interface EnableSpringPersistentTasksJpaRepositories {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.sterl.spring.persistent_tasks.config;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Role;
import org.sterl.spring.persistent_tasks.EnableSpringPersistentTasksEntityScan;

@EntityScan(basePackageClasses = EnableSpringPersistentTasksEntityScan.class)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class EnableSpringPersistentTasksEntityScanConfig {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.sterl.spring.persistent_tasks.config;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.sterl.spring.persistent_tasks.EnableSpringPersistentTasksJpaRepositories;

@EnableJpaRepositories(basePackageClasses = EnableSpringPersistentTasksJpaRepositories.class)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class EnableSpringPersistentTasksJpaRepositoriesConfig {

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.sterl.spring.persistent_tasks;
package org.sterl.spring.persistent_tasks.config;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.sterl.spring.persistent_tasks.EnableSpringPersistentTasks;

@Configuration
@EnableScheduling
@EnableAsync
@AutoConfigurationPackage(basePackageClasses = EnableSpringPersistentTasks.class)
@ComponentScan(basePackageClasses = EnableSpringPersistentTasks.class)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class SpringPersistentTasksConfig {

}
8 changes: 8 additions & 0 deletions doc/docs/maven-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
public class ExampleApplication {
```

Include corresponding annotation if you use:

- `@EntityScan` ->` @EnableSpringPersistentTasksEntityScan`
- `@EnableJpaRepositories` -> `@EnableSpringPersistentTasksJpaRepositories`
- `@EnableEnversRepositories` ->` @EnableSpringPersistentTasksJpaRepositories`

They break the spring auto configuration.

# DB using liquibase

Dependency needed to setup the DB using liquibase
Expand Down
10 changes: 8 additions & 2 deletions example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.12</version>
<version>3.4.10</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

Expand All @@ -17,7 +17,7 @@
<!--
<spt.version>2.1.2</spt.version>
-->
<spt.version>2.2.1</spt.version>
<spt.version>2.2.3-SNAPSHOT</spt.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -48,6 +48,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-envers</artifactId>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<properties>
<java.version>21</java.version>
<spring-boot.version>3.4.7</spring-boot.version>
<spring-boot.version>3.4.10</spring-boot.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Loading