副标题:JDK安装到Maven运行
关键字:JDK + SVN + Maven + Tomcat + Eclipse + IDEA
一、JDK
1、JDK包
JDK包 | ../Java/jdk1.8 # 按需 |
图例 |
|
2、环境变量
步骤 | 计算机 → 属性 → 高级系统设置 → 环境变量 → 系统变量 → 新建/编辑 |
设置 | JAVA_HOME = ../Java/jdk1.8 Path += %JAVA_HOME%; CLASSPATH = . |
图例 |
|
二、IDEA
1、注册激活
步骤 | Help → Register → License server |
设置 | License server address = http://idea.iteblog.com/key.php |
图例 |
|
2、字体大小
步骤 | File → Settings → Editor → Font |
设置 | Font = Consolas # 按需 Size = 16 Fallback font = Source Code Pro |
图例 |
|
3、字符编码
步骤 | File → Settings → Editor → File Encodings |
设置 | Encoding = UTF-8 |
图例 |
|
三、Eclipse
1、字体大小
步骤 | Window → Preferences → General → Appearance → Colors and Font → Basic → Text Font |
设置 | 字体 = 微软雅黑 # 按需 大小 = 小四 |
图例 |
|
2、背景颜色
步骤 | Window → Preferences → General → Editors → Text Editors → Appearance color options → Background color |
设置 | 色调 = 85 饱和度 = 120 亮度 = 208 |
图例 |
|
3、字符编码
步骤 | Window → Preferences → General → Workspace → Text file encoding |
设置 | Other = UTF-8 |
图例 |
|
四、Maven包
Maven包 | ../maven/apache-maven-3.5.2 # 按需 |
Maven库 | ../maven/repository # 按需 |
配置文件 | ../maven/settings.xml # 按需 |
环境变量 | MAVEN_HOME = ../maven/apache-maven-3.5.2 # 可选项 Path += %MAVEN_HOME%/bin; |
图例 |
|
五、Tomcat包
Tomcat包 | ../tomcat # 按需 |
环境变量 | CATALINA_BASE = ../tomcat # 可选项 CATALINA_HOME = ../tomcat Path += %CATALINA_HOME%/lib;%CATALINA_HOME%/bin; |
图例 |
|
六、SVN客户端
SVN包 | ../svn # 按需 |
环境变量 | Path += ../svn/bin; # 自动添加 |
图例 |
|
七、IDEA + JDK + SVN + Maven + Tomcat
1、默认设置
(1)默认SDK
步骤 | File → Other Settings → Default Project Structure → Platform Settings → SDKs → + → JDK |
配置 | 路径选择 ../Java/jdk1.8 |
图例 |
|
步骤 | File → Other Settings → Default Project Structure → Project Settings → Project → Project SDK → New |
设置 | 路径选择 ../Java/jdk1.8 |
图例 |
|
(2)默认Maven
步骤 | File → Other Settings → Default Settings → Build,Execution,Deployment → Build Tools → Maven |
设置 | Maven home directory = ../maven/apache-maven-3.5.2 # 按需 User settings file = ../maven/settings.xml # 按需 Local repository = ../maven/repository # 按需 |
图例 |
|
步骤 | File → Other Settings → Default Settings → Build,Execution,Deployment → Build Tools → Maven → Runner |
设置 | VM Options = -Xms512m -Xmx1024m JRE = ../Java/jdk1.8 |
图例 |
|
(3)默认Tomcat
步骤 | File → Settings → Build,Execution,Deployment → Application Servers → + |
设置 | Name = Tomcat.pluginName # 自拟 Tomcat Home = ../tomcat # 按需 Tomcat base directory = ../tomcat |
图例 |
|
2、项目配置
(1)SVN检出
步骤 | File → New → Project from Version Control → Subversion → + |
设置 | Repository URL = ../Project.name/trunk # 按需 |
图例 |
|
(2)项目Maven
步骤 | Run → Edit Configurations → + → Maven → Parameters |
设置 | Name = Maven.runName # 自拟 Working directory = ../space/Project.name # 按需 Command line = tomcat7:run √Resolve Workspace artifacts |
图例 |
|
(3)项目Server
步骤 | Run → Edit Configurations → + → Tomcat Server → Local → Server |
设置 | Name = Tomcat.runName # 自拟 Application server = Tomcat.pluginName After launch = Chrome,http://127.0.0.1:8080/ # 按需 VM options = -Xms512m -Xmx1024m On Update action = Restart server # 热部署 JRE = Default 或 ../Java/jdk1.8/jre HTTP port = 8080 # 按需 |
图例 |
|
步骤 | Run → Edit Configurations → + → Tomcat Server → Local → Deployment |
设置 | + = Project.name:war exploded Application context = /Project.name # 自拟 |
图例 |
|
3、启动项目
Maven启动 | Run Maven.runName # 按需 Debug Maven.runName |
Tomcat启动 | Run Tomcat.runName # 按需 Debug Tomcat.runName |
图例 |
|
八、Eclipse + JDK + SVN + Maven + Tomcat
1、默认配置
(1)默认JDK
步骤 | Window → Preferences → Java → Installed JREs → Add → Standard VM |
设置 | JRE home = ../Java/jre1.8 JRE name = jre1.8 Default VM arguments = -Xms512m -Xmx1024m |
图例 |
|
(2)默认Maven
步骤 | Window → Preferences → Maven → Installations → Add |
设置 | Installation home = ../maven/apache-maven-3.5.2 Installation name = Maven.pluginName # 自拟 |
图例 |
|
步骤 | Window → Preferences → Maven → User Settings |
设置 | User Settings = ../maven/settings.xml Local Repository = ../maven/repository |
图例 |
|
(3)默认Tomcat
步骤 | Window → Preferences → Server → Runtime Environments → Add → Apache → Apache Tomcat v7.0 |
设置 | Name = Tomcat.pluginName # 自拟 Tomcat installation directory = ../tomcat JRE = Default JRE 或 jre1.8 |
图例 |
|
步骤 | Window → Show View → Servers → 单击link → Tomcat v7.0 Server → Next → Add Project |
设置 | Server Name = Tomcat.runName # 自拟 Server runtime environment = Tomcat.pluginName # 按需 |
图例 |
|
步骤 | Servers → 双击Tomcat.runName → Server Options |
设置 | √Publish module contexts to separate XML files # 保存 |
图例 |
|
步骤 | Servers → 双击Tomcat.runName → Timeouts |
设置 | Start(in seconds) = 90 |
图例 |
步骤 | Servers → 双击Tomcat.runName → Ports |
设置 | Tomcat admin port = 8005 HTTP/1.1 = 8080 AJP/1.3 = 8009 |
图例 |
2、项目配置
(1)SVN检出
步骤 | File → New → Project → SVN → 从SVN检出项目 → 创建新的资源库位置 → ... → 作为工作空间中的项目检出 |
设置 | URL = ../Project.name/trunk # 按需 项目名称 = Project.name # 按需 |
图例 |
|
(2)项目Maven
步骤 | 项目 → Delete (×Delete project contents on disk) File → Import → Maven → Existing Maven Projects # 参考链接
|
设置 | Root Directory = ../space/Project.name √Add project(s) to working set |
图例 |
|
步骤 | Run → Run Configurations → Maven Build → New → Main |
设置 | Name = Maven.runName # 自拟 Base directory = ${workspace_loc:/Project.name} # 参考链接 Goals = tomcat7:run -Dmaven.tomcat.port=8080 # 按需 Profiles = dev # 参考链接 |
图例 |
|
步骤 | Run → Run Configurations → Maven Build → New → JRE |
设置 | VM arguments = -Xms512m -Xmx1024m |
图例 |
|
步骤 | Run → Run Configurations → Maven Build → New → Source → Add → Project → Choose project(s) to add |
图例 |
|
(3)项目Server
步骤 | Servers → Tomcat.pluginName → Add and Remove |
设置 | 选择当前项目Add |
图例 |
|
3、启动项目
Maven启动 | Run Maven.runName # 按需 Debug Maven.runName |
Tomcat启动 | Run Tomcat.runName # 按需 Debug Tomcat.runName |
图例 |
|
参考资料
【1】《Eclipse外部工具的变量引用》,链接
【2】《Eclipse的SVN方式检出Maven项目》,链接
【3】《Maven的Profile介绍》,链接
【4】《IDEA、WebStorm、Pycharm破解办法》,链接
【5】《IDEA的Tomcat配置详解》,链接