Spring SpEL - 建立專案



使用 eclipse,選擇檔案新建Maven 專案。勾選建立簡單專案(跳過原型選擇)並點選下一步。

輸入詳細資訊,如下所示:

  • groupId − com.tutorialspoint

  • artifactId − springspel

  • version − 0.0.1-SNAPSHOT

  • name − springspel

  • description − Spring SpEL 專案

點選完成按鈕,將建立一個新專案。

pom.xml

使用 Spring Core 依賴項更新 pom.xml。以下是 pom.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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.tutorialspoint</groupId>
   <artifactId>springspel</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <name>springspel</name>
   <description>Spring SpEL Project</description>
   <properties>
      <org.springframework.version>5.3.9</org.springframework.version>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <java.version>1.8</java.version>    
   </properties> 
   <dependencies>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context</artifactId>
         <version>${org.springframework.version}</version>
         <scope>compile</scope>
      </dependency>
   </dependencies>	    
   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
               <source>${java.version}</source>
               <target>${java.version}</target>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

applicationcontext.xml

src → main → resources中建立 applicationcontext.xml,內容如下。

applicationcontext.xml

<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
   xsi:schemaLocation="http://www.springframework.org/schema/beans   
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  
</beans> 
廣告

© . All rights reserved.