idea创建springboot项目maven管理启动

本文详细介绍如何使用IntelliJ IDEA快速创建Spring Boot项目,包括配置本地Maven仓库、设置JDK版本及启动项目的全过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本篇文章是新手使用idea快速搭建springboot工程全流程的详解和启动过程。

1、idea快速创建springboot工程

  • 点击左上角file–>new–>project进入创建项目页面
    在这里插入图片描述
  • 选择spring initializr和对应的jdk版本

在这里插入图片描述

  • 点击下一步,编辑项目相关信息
    在这里插入图片描述

  • 选择对应使用的springboot版本
    在这里插入图片描述

  • 确认项目信息,点击finish
    在这里插入图片描述

  • 创建完成基本的springboot项目框架
    在这里插入图片描述

  • 设置本地maven信息
    在这里插入图片描述

  • 具体maven的setting文件如下,如果仓库地址不对可能下载不下来对应jar

<?xml version="1.0" encoding="UTF-8" ?>
 
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->
 
<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.home}/conf/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <!-- localRepository
     | The path to the local repository maven will use to store artifacts.
     |
     | Default: ${user.home}/.m2/repository
    <localRepository>/path/to/local/repo</localRepository>
    -->
    <!--自定义本地仓库路径-->
    <localRepository>D:\newHealthRepository</localRepository>
    <!-- interactiveMode
     | This will determine whether maven prompts you when it needs input. If set to false,
     | maven will use a sensible default value, perhaps based on some other setting, for
     | the parameter in question.
     |
     | Default: true
    <interactiveMode>true</interactiveMode>
    -->
 
    <!-- offline
     | Determines whether maven should attempt to connect to the network when executing a build.
     | This will have an effect on artifact downloads, artifact deployment, and others.
     |
     | Default: false
    <offline>false</offline>
    -->
 
    <!-- pluginGroups
     | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
     | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
     | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
     |-->
    <pluginGroups>
        <!-- pluginGroup
         | Specifies a further group identifier to use for plugin lookup.
        <pluginGroup>com.your.plugins</pluginGroup>
        -->
    </pluginGroups>
 
    <!-- proxies
     | This is a list of proxies which can be used on this machine to connect to the network.
     | Unless otherwise specified (by system property or command-line switch), the first proxy
     | specification in this list marked as active will be used.
     |-->
    <proxies>
        <!-- proxy
         | Specification for one proxy, to be used in connecting to the network.
         |
        <proxy>
          <id>optional</id>
          <active>true</active>
          <protocol>http</protocol>
          <username>proxyuser</username>
          <password>proxypass</password>
          <host>proxy.host.net</host>
          <port>80</port>
          <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>
        -->
    </proxies>
 
    <!-- servers
     | This is a list of authentication profiles, keyed by the server-id used within the system.
     | Authentication profiles can be used whenever maven must make a connection to a remote server.
     |-->
    <servers>
      
    </servers>
    <mirrors>
	<mirror>
  <id>aliyunmaven</id>
  <mirrorOf>*</mirrorOf>
  <name>阿里云公共仓库</name>
  <url>https://maven.aliyun.com/repository/public</url>
</mirror>

        <mirror>
            <id>alimaven-central</id>
            <mirrorOf>central</mirrorOf>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
        </mirror>
        <mirror>
            <id>jboss-public-repository-group</id>
            <mirrorOf>central</mirrorOf>
            <name>JBoss Public Repository Group</name>
            <url>http://repository.jboss.org/nexus/content/groups/public</url>
        </mirror>
    </mirrors>
    <profiles>
        <profile>
            <id>jdk18</id>
            <activation>
                <jdk>1.8</jdk>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
 
    </profiles>
</settings>
  • 确认模块的编译版本和pom是否一致
    在这里插入图片描述
    在这里插入图片描述
  • 启动项目
    如果启动报错:无效的目标发行版17,修改下面截图的参数再启动。
    在这里插入图片描述
    启动成功
    在这里插入图片描述
    后面可以根据自己想测试的技术点,增加配置文件,pom依赖和具体代码demo,开始搞起来吧!
### 如何在 IntelliJ IDEA 中使用 Maven 创建 Spring Boot 项目 #### 打开 IntelliJ IDEA 启动 IntelliJ IDEA 后,在欢迎界面点击 "Create New Project" 或者对于已经打开 IDE 的情况,选择 `File` -> `New` -> `Project...`。 #### 配置新项目 在弹出的新建项目窗口中,选择左侧列表中的 `Spring Initializr`。这会自动设置好用于创建 Spring Boot 应用程序的基础环境[^1]。 #### 设置项目元数据 按照提示输入项目的名称、位置以及其他必要的信息。确保选择了合适的 Java 版本以及勾选了 `Use artifact IDs as module names` 和 `Search for updates automatically` 复选框来保持依赖项最新。 #### 添加依赖关系 进入下一步后可以看到可用的 Starter Dependencies 列表。这里可以根据需求添加所需的模块支持,比如 Web 支持 (`spring-boot-starter-web`) 来开发 RESTful API 接口服务等。通过这种方式可以快速搭建起具有特定功能集的应用骨架结构[^2]。 #### 完成并导入项目 完成上述配置之后点击 “Finish”,等待几秒钟让 IntelliJ 自动下载所需库文件并将它们加入到工程当中去。此时应该可以在项目视图里看到标准的 Maven 文件夹布局和自动生成好的主类文件(通常命名为 Application.java),其中包含了应用程序入口方法 main() 函数定义。 ```java @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值