IntelliJ IDEA 创建maven web项目2(6)

本文介绍如何使用IntelliJ IDEA创建Maven Web项目,并配置Maven的settings.xml文件来使用阿里云镜像。同时展示了如何启用自动导入功能及添加依赖,最后给出了一个读取资源文件的例子。

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

使用IntelliJ IDEA 创建maven web项目


<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<localRepository>D:\repository</localRepository>
</settings>
从网上下载Maven3.3.9版本(可以更高),然后改写里面settings.xml。如上。

点击Enable Auto Import

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.5</version>
</dependency>

资源文件的访问

Properties properties = new Properties();
properties.load(getClass().getResourceAsStream("/mydb.properties"));
out.write("url:"+properties.getProperty("jdbc_url")+"\n");
out.write("username:"+properties.getProperty("jdbc_username")+"\n");
out.write("jdbc_password:"+properties.getProperty("jdbc_password")+"\n");

在需要测试的类中如下图所示:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值