# Spring

提供一個 all-in-one 的開發環境（設定）， 基本上是下面幾個要點組成， 所以不一定要用 \[spring initializr] 產生：

* pom.xml

  ```markup
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>版本號碼</version>
        <relativePath/>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- 開發階段用 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>    
        <dependency>
            <!-- 偵測檔案變動自動重起 Tomcat -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
  ```
* 傳統 Java application class

  ```java
    @SpringBootApplication
    public class SpringApp {
        public static void main(String[] args) {
            SpringApplication.run(SpringApp.class, args);
        }
    }
  ```

也不需要 `mvnw`，直接下 `mvn spring-boot:run` 就行。

\[spring initializr]: <http://start.spring.io>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.psmonkey.org/ruan-ti-kai-fa/java/spring.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
