发表于: 2020-04-01 19:08:20
1 1608
IntelliJ的操作
1.常用快捷键:
⌃ (↓ / ↑) ⌘ ⌥ (← / →) ⌘ (B / 鼠标点击) ⌘ E ⌃ R ⌃ D ⌘, ⌘; | 跳转到 跳转到 跳转到光标所在的 弹出 运行 调试 preferences project structures |
Mac参考:https://www.jianshu.com/p/e1f7deef3ec2
Windows参考:https://www.cnblogs.com/unidentified/p/9182655.html
2.安装插件:
settings-> plugins 需要重启
3.防止用中文的地方乱码
preferences⌘, ->editors-> file encodings->project encodings & default encodings for property files配置文件: UTF-8
Maven
1.依赖
Maven仓库是项目中依赖的第三方库 参考:https://www.runoob.com/maven/maven-repositories.html
Maven 仓库有三种类型:
- 本地(local)
- 中央(central)
- 远程(remote)
1.想安装更多依赖(依赖导入):
左边project目录->pom.xml-><dependencies> 加入依赖</dependencies>
找想要的包去maven仓库搜索 https://mvnrepository.com/
eg. junit测试包->4.12(下载最多最稳定版本)-> copy maven描述xml语句 -> 贴在dependencies里 (找这个包的时候先在local找,没有就去远程下载到m2,然后去中央) -> junit出现在external libraries里
下载到本地的包放在:我的电脑 ->C盘 -> 用户-> dell -> .m2仓库m2/repository
2..m2文件夹的settings配置文件:
local repositories本地仓库位置, (可以换成E盘E:/.../,默认m2/repository)
settings配置文件细节说明:https://www.cnblogs.com/jingmoxukong/p/6050172.html
<mirrors></mirrors>中央仓库 的镜像,从中央仓库下载包 eg.搜索alibaba的中央仓库的配置并贴进mirrors
3. 左边栏maven pom配置 参考:https://www.jianshu.com/p/0e3a1f9c9ce7 https://blog.csdn.net/qq_33363618/article/details/79438044
<groupId>公司
<artifactId>项目
<version>版本
2.maven常用命令
右边maven->lifecycles
clean-target文件夹会消失
install-出现target文件夹、m2仓库可以找到这个新建的project eg. /repository/cn/Esther/shu_task1(project名)
package eg.打包插件
eg. 新建class: java文件夹->右键new->class 运行后左边会出现target/class下的class文件
写一个测试类 psvm(快捷main function)->sout(快捷输出)
自己install时出现Error:
不再支持源选项 5。请使用 7 或更高版本。
不再支持目标选项 5。请使用 7 或更高版本。
解决:在pom.xml里贴了以下
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<java.version>12</java.version>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
然后install, target/class下出现了class文件
main function旁边小绿箭头运行后,报错Error:java: 错误: 不支持发行版本 12
解决:改装java 8 ,下载jdk https://www.oracle.com/java/technologies/javase-jdk8-downloads.html
new project->引入新jdk(找安装的java jdk本机地址:terminal输入 /usr/libexec/java_home -V)-> 然后选java1.8...那个文件夹
1.检查⌘, ->Build, Execution and Deployment->Java compiler ->project byte code version是8
2.检查⌘;->1.project ->project sdk和language Level是java1.8
->2.Modules 是java1.8
再次运行main class成功输出
下次计划的事情:(java的常用语法)
收获:(如何创建maven,依赖导入,maven常用命令)
评论