Java 创建springframeworkstarter项目,而不是springboot

Java 创建springframeworkstarter项目,而不是springboot,java,spring,Java,Spring,我正在从事一个使用Spring Framework3.2.11.RELEASEversion的项目,我们想在其中实现一些新东西,但在我想制作一个小型Rest API之前,我想做一个概念验证应用程序。这个小型RESTAPI必须使用与原始API相同的包(不,更新主项目不是一个选项) 当使用它时,我得到了一个很好的项目,但是使用SpringBoot,这不是我想要的。使用ZR提供的项目初始值,我将pom.xml更改为使用与原始项目相同的spring包: <?xml version="1.

我正在从事一个使用Spring Framework
3.2.11.RELEASE
version的项目,我们想在其中实现一些新东西,但在我想制作一个小型Rest API之前,我想做一个概念验证应用程序。这个小型RESTAPI必须使用与原始API相同的包(不,更新主项目不是一个选项)

当使用它时,我得到了一个很好的项目,但是使用SpringBoot,这不是我想要的。使用ZR提供的项目初始值,我将
pom.xml
更改为使用与原始项目相同的spring包:

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project </description>
    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.2.11.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.2.11.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>3.2.11.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.2.11.RELEASE</version>
        </dependency>
    </dependencies>

</project>

如果尚未向当前的
SpringBoot
应用程序添加任何业务逻辑,则可以使用
Eclipse
STS
IDE创建新的Spring项目。您的测试人员或主类将如下所示:

import org.springframework.beans.factory.BeanFactory;  
import org.springframework.beans.factory.xml.XmlBeanFactory;  
import org.springframework.core.io.ClassPathResource;  
import org.springframework.core.io.Resource;  
  
public class Test {  
public static void main(String[] args) {  
    Resource resource=new ClassPathResource("applicationContext.xml");  
    BeanFactory factory=new XmlBeanFactory(resource);  
      
    Student student=(Student)factory.getBean("studentbean");  
    student.displayInfo();  
}  
}  
    <?xml version="1.0" encoding="UTF-8"?>  
    <beans  
        xmlns="http://www.springframework.org/schema/beans"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xmlns:p="http://www.springframework.org/schema/p"  
        xsi:schemaLocation="http://www.springframework.org/schema/beans  
                   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  
      
    <bean id="studentbean" class="com.app.Student">  
    <property name="name" value="Student1"></property>  
    </bean>  
      
    </beans> 
(我在IDE中创建了
Student
类,这就是为什么只为演示而使用该类的实例) 您的
.xml
文件应该如下所示:

import org.springframework.beans.factory.BeanFactory;  
import org.springframework.beans.factory.xml.XmlBeanFactory;  
import org.springframework.core.io.ClassPathResource;  
import org.springframework.core.io.Resource;  
  
public class Test {  
public static void main(String[] args) {  
    Resource resource=new ClassPathResource("applicationContext.xml");  
    BeanFactory factory=new XmlBeanFactory(resource);  
      
    Student student=(Student)factory.getBean("studentbean");  
    student.displayInfo();  
}  
}  
    <?xml version="1.0" encoding="UTF-8"?>  
    <beans  
        xmlns="http://www.springframework.org/schema/beans"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xmlns:p="http://www.springframework.org/schema/p"  
        xsi:schemaLocation="http://www.springframework.org/schema/beans  
                   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  
      
    <bean id="studentbean" class="com.app.Student">  
    <property name="name" value="Student1"></property>  
    </bean>  
      
    </beans> 

我希望这能对你有所帮助