运行学长的Eclipse
工程,遭遇了无数的坑,整理如下,造福后人.
直接从Git导入工程
配置GitHub账号
打开
Eclipse
,进入整个Eclipse
的Properties
Type “git” in the search bar, then choose that path ‘Team > Git > Configuration’. Click ‘Add Entry…’.
Enter
user.name
as the Key, and your GitHub username as the Value, then add another entry withuser.email
as the Key and your corresponding email as the Value. (就是GitHub的用户名和邮箱)Import the repo into Eclipse
We don’t yet physically have a local copy of the repo, but Eclipse is going to take care of the details for us.
- Open Eclipse, with E-Git installed (you will quickly find out if you have an older version without it).
- In Eclipse, choose ‘File’ (top left), then ‘Import…’
- In the dialog that opens, choose ‘Git > Projects from Git’ and click ‘Next’
- Click on ‘Clone URI’, then click ‘Next’ 复制Git上的
https
地址(而不是ssh) - Here’s where some magic happens: on this next screen the details should already be filled out for you, as shown below. Ensure that your GitHub username and password are entered under ‘Authentication’, and click Next.
会显示在
Git Repositories
标签页中(只是有了repository,依然需要) 导入工程
在刚刚clone下来的repository上右键,
Import Projects
选择General
->Existing projects from file system or archive
(或是另一个),才能检测到project
Build Path 配置
更换JDK版本,可以在
Eclipse
的Properties
中将java
->installed JDKs
更换(这种方法修改的是workplace default JDK),也可以在Project Properties
中修改package的路径问题
代码里定义的包名是
com.yancloud.sc.servlet
但是直接打开工程后把src.com.yancloud.sc.servlet
直接缩到了一起,需要改Build PATH
中的source
,把它们拆成两级目录缺少 javax, websocket等包,在Tomcat的
lib
文件夹下有,我直接把所有的包都加进去了
Tomcat Server 配置
在Eclipse中安装Tomcat Server
https://www.baeldung.com/eclipse-tomcat
这个链接的2步骤
项目
Properties
->Facets
选中
Dynamic Web Module
Java
JavaScript
三项,注意Java的版本也要和Library的版本对应上执行上面链接4
执行代码
可以直接运行test
文件夹下的测试程序(含有main函数,可以独立运行)
我运行时出现了has been compiled by a more recent version of the Java Runtime
错误,后来发现是project的Properties
-> Java Compiler
没有改成对应的JDK版本