Windows JPA@实体的STS 3.9.11@自动连线不再适用于STS 4.5.1

Windows JPA@实体的STS 3.9.11@自动连线不再适用于STS 4.5.1,windows,eclipse,maven,spring-tool-suite,jdk1.7,Windows,Eclipse,Maven,Spring Tool Suite,Jdk1.7,我们正准备用JDK11(Tomcat9)将传统的JDK1.7Spring工具套件3WebApp(Tomcat8)迁移到STS4 如果我将maven项目导入STS 3.9.11,某些@Entity类的@AutoWired属性将被填充,但如果我在STS 4.5.1(仍然是JDK 1.7)中导入相同的projet,这将停止工作 我已经研究了为什么注入在@Entity中不起作用,很显然这是正常的,类被实例化为db框架,而不是Spring框架。解决方法之一是使用SpringBeanAuthoringSup

我们正准备用JDK11(Tomcat9)将传统的JDK1.7Spring工具套件3WebApp(Tomcat8)迁移到STS4

如果我将maven项目导入STS 3.9.11,某些@Entity类的@AutoWired属性将被填充,但如果我在STS 4.5.1(仍然是JDK 1.7)中导入相同的projet,这将停止工作

我已经研究了为什么注入在@Entity中不起作用,很显然这是正常的,类被实例化为db框架,而不是Spring框架。解决方法之一是使用SpringBeanAuthoringSupport扩展@Entity类,或者创建某种“context.xml”来完成同样的工作(我对Spring、Beans和JPA是新手)

我想知道为什么它使用STS3、9.11而不是STS4.5.1,以及使用JDK11的最佳解决方案是什么

superprom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ca.qc.gouv.cnt.superpom</groupId>
<artifactId>SuperPom</artifactId>
<version>1.0.0.RELEASE</version>
<packaging>pom</packaging>
<properties>
    <java.version>7</java.version>
    <war.name>DEFAULT_WAR_NAME</war.name>
    <aspectj.version>1.7.4</aspectj.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
    <repository>
      <id>central</id>
      <url>http://repo1.maven.org/maven2</url>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
</repositories> 

<pluginRepositories>
    <pluginRepository>
        <id>central</id>
        <name>Maven Plugin Repository</name>
        <url>http://repo1.maven.org/maven2</url>
        <layout>default</layout>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <releases>
            <updatePolicy>never</updatePolicy>
        </releases>
    </pluginRepository>
</pluginRepositories>
<dependencies>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${aspectj.version}</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>create-timestamp</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <doCheck>false</doCheck>
                <doUpdate>false</doUpdate>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <warName>${war.name}</warName>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <archive>
                    <manifestEntries>
                        <Implementation-Build>${timestamp}</Implementation-Build>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.4</version>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <phase>process-sources</phase>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <outxml>true</outxml>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <weaveWithAspectsInMainSourceFolder>false</weaveWithAspectsInMainSourceFolder>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.codehaus.mojo</groupId>
                                    <artifactId>buildnumber-maven-plugin</artifactId>
                                    <versionRange>[1.3,)</versionRange>
                                    <goals>
                                        <goal>create-timestamp</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute></execute>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
WebAppConfig.java:

@Bean
public BottinService bottinService() {
    BottinService bottinService = new BottinService();
    bottinService.setCacheMinutes(10);
    return bottinService;
}

它现在与STS 4.5.1一起使用。我在控制台(mvn.cmd clean install)的命令行上构建了5个相互依赖的项目,并修复了SuperPom.xml和Pom.xml中的错误(AspectJ没有找到超类对象,javax.annotation不在那里)

如果我只使用Eclipse菜单进行构建,ProjectMaven更新、清理,然后安装,那么在构建过程中就不会再有错误,@Autowire在STS3.9.11中的工作方式与以前一样

从这篇文章中得出以下想法:

我已打开日志记录功能。工作版本和非工作版本中的bean创建序列之间存在差异。工作一:“-已完成创建bean‘localeResolver’的实例,并返回单例bean‘bottinService’的缓存实例”。版本:“已完成创建bean'viewResolver'的实例,返回singleton bean'bottinService'的缓存实例”很难说为什么在STS 3.x中使用此项目与在STS 4.x中使用此项目有什么不同。你能打开一个问题,并附上一个样本项目,让我们看看吗?
@Entity
@Configurable
@Table(name = "SADR11_SUBST_APLIC_INTRV")
public class Substitution extends BaseAuditable {
    
    @Transient
    @Autowired
    private BottinService bottinService;
@Bean
public BottinService bottinService() {
    BottinService bottinService = new BottinService();
    bottinService.setCacheMinutes(10);
    return bottinService;
}