BAEL-4068 Remove AspectJ DI from module spring-di
This commit is contained in:
parent
580a3bb920
commit
fd16e9ed4f
spring-di
@ -68,11 +68,6 @@
|
|||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
<version>${spring-boot.version}</version>
|
<version>${spring-boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-test</artifactId>
|
<artifactId>spring-boot-test</artifactId>
|
||||||
@ -95,11 +90,7 @@
|
|||||||
<artifactId>aspectjweaver</artifactId>
|
<artifactId>aspectjweaver</artifactId>
|
||||||
<version>${aspectjweaver.version}</version>
|
<version>${aspectjweaver.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-aspects</artifactId>
|
|
||||||
<version>${spring.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>org.springframework</groupId>-->
|
<!-- <groupId>org.springframework</groupId>-->
|
||||||
@ -138,27 +129,6 @@
|
|||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>aspectj-maven-plugin</artifactId>
|
|
||||||
<version>${aspectj-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<complianceLevel>${java.version}</complianceLevel>
|
|
||||||
<aspectLibraries>
|
|
||||||
<aspectLibrary>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-aspects</artifactId>
|
|
||||||
</aspectLibrary>
|
|
||||||
</aspectLibraries>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>compile</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@ -194,7 +164,6 @@
|
|||||||
<mockito.version>1.10.19</mockito.version>
|
<mockito.version>1.10.19</mockito.version>
|
||||||
<assertj.version>3.12.2</assertj.version>
|
<assertj.version>3.12.2</assertj.version>
|
||||||
<aspectjweaver.version>1.9.5</aspectjweaver.version>
|
<aspectjweaver.version>1.9.5</aspectjweaver.version>
|
||||||
<aspectj-plugin.version>1.11</aspectj-plugin.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -1,9 +0,0 @@
|
|||||||
package com.baeldung.di.aspectj;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.aspectj.EnableSpringConfigured;
|
|
||||||
|
|
||||||
@ComponentScan
|
|
||||||
@EnableSpringConfigured
|
|
||||||
public class AspectJConfig {
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package com.baeldung.di.aspectj;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class IdService {
|
|
||||||
private static int count;
|
|
||||||
|
|
||||||
int generateId() {
|
|
||||||
return ++count;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package com.baeldung.di.aspectj;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Configurable;
|
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Transient;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Configurable(preConstruction = true)
|
|
||||||
public class PersonEntity {
|
|
||||||
@Autowired
|
|
||||||
@Transient
|
|
||||||
private IdService idService;
|
|
||||||
|
|
||||||
@Id
|
|
||||||
private int id;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public PersonEntity() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public PersonEntity(String name) {
|
|
||||||
id = idService.generateId();
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package com.baeldung.di.aspectj;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Configurable;
|
|
||||||
|
|
||||||
@Configurable
|
|
||||||
public class PersonObject {
|
|
||||||
@Autowired
|
|
||||||
private IdService idService;
|
|
||||||
|
|
||||||
private int id;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public PersonObject(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateId() {
|
|
||||||
this.id = idService.generateId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package com.baeldung.di.aspectj;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@ContextConfiguration(classes = AspectJConfig.class)
|
|
||||||
public class PersonUnitTest {
|
|
||||||
@Test
|
|
||||||
public void givenUnmanagedObjects_whenInjectingIdService_thenIdValueIsCorrectlySet() {
|
|
||||||
PersonObject personObject = new PersonObject("Baeldung");
|
|
||||||
personObject.generateId();
|
|
||||||
assertEquals(1, personObject.getId());
|
|
||||||
assertEquals("Baeldung", personObject.getName());
|
|
||||||
|
|
||||||
PersonEntity personEntity = new PersonEntity("Baeldung");
|
|
||||||
assertEquals(2, personEntity.getId());
|
|
||||||
assertEquals("Baeldung", personEntity.getName());
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user