20201214-IDEA使用中遇到的问题

IDEA本地仓库的指定及还会出现下载jar包的解决办法:

首先打开软件的安装目录:我的是D:\develop\apache-maven-3.5.2
在这里插入图片描述
打开conf下的settings.xml文件。
在这里插入图片描述
找到文件中下面位置,并加入红色方框中的一句代码,其中的地址就是本地仓库的地址
在这里插入图片描述
至此,本地仓库设置完毕。

下面讲一个我遇到的一个问题:我之前指定了本地仓库还要下载jar包的问题。

这是我创建的小工程:
在这里插入图片描述
下面是父层的pom.xml文件,红色方框是指定的框架版本,如果不指定框架版本的话,工程会找不到本地jar包,并且会重新下载jar包。所以框架版本是必须要的。
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
IDEA 开发环境使用 Maven 项目时,可以使用 profile 来指定不同的环境。通常情况下,我们会为开发、测试和部署环境创建不同的 profile。具体步骤如下: 1. 在 pom.xml 文件,添加 profile 标签。 ``` <profiles> <profile> <id>dev</id> <properties> <env>dev</env> </properties> </profile> <profile> <id>test</id> <properties> <env>test</env> </properties> </profile> <profile> <id>prod</id> <properties> <env>prod</env> </properties> </profile> </profiles> ``` 这里我们创建了三个 profile,分别对应着 dev、test 和 prod 环境。 2. 在 pom.xml 文件,添加 build 标签,并在其引用 profile。 ``` <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> <executions> <execution> <id>default-copy-resources</id> <phase>process-resources</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/classes</outputDirectory> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> </build> ``` 这里我们使用 Maven 插件 maven-resources-plugin,将 src/main/resources 目录的资源文件复制到 target/classes 目录,并在复制的过程进行过滤,替换其的占位符。 3. 在 resources 目录,创建三个文件夹 dev、test 和 prod,并在其创建一个名为 application.properties 的文件。 ``` src/main/resources/ ├── dev │ └── application.properties ├── prod │ └── application.properties └── test └── application.properties ``` 这里我们为每个环境创建了一个 application.properties 文件,用于存放该环境的配置信息。 4. 在 application.properties 文件,添加一些配置信息。 ``` server.port=8080 spring.datasource.url=jdbc:mysql://localhost:3306/mydb spring.datasource.username=root spring.datasource.password=root ``` 这里我们添加了一些常用的配置信息。 5. 在 IDEA 开发环境,选择 Edit Configurations,在其添加一个 Maven 配置。 6. 在 Command line 输入以下命令: ``` clean install -Pdev ``` 这里的 -P 参数表示指定 profile,这里我们指定了 dev 环境。 7. 点击 OK,保存配置。 现在,我们可以在 dev 环境运行项目了。如果需要在其他环境运行项目,只需要更改 Command line 的 profile 参数即可。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值