Windows 平台 JavaEE 基本开发环境搭建

1 安装JDK

1.1下载

地址 http://www.oracle.com/technetwork/java/javase/downloads/index。
直接官网下载安装,注意版本对应,如果是老机器,要注意下载以应的x86而不是x64版本。

1.2 安装 JDK

运行安装包,一路 next, 中途可选择安装路径和内容,如果只是纯开发,可以不装 Public JRE。

1.3 设置系统变量

在用户变量处新增一个 JAVA_HOME 变量,值为 JDK 的安装路径;
在用户变量的 Path 变量的值新增 %JAVA_HOMR%/bin。

1.4 测试

运行 cmd, 输入 java -version, 如果能正确显示相关信息,表明安装成功。

2. 安装 Eclipse

2.1 下载 Eclipse

地址 https://www.eclipse.org/downloads/eclipse-packages/
要注意下载的版本
是进行javaee下载,因此是带了jee插件的eclipse

2.2 安装 Eclipse

把压缩包的内容解压到一个你平常放软件的路径,最好不要有中文、空格或特殊字符,然后新建一个 eclipse.exe 的快捷方式方便运行就可以了。

2.3 Eclipse 简单配置

第一次运行 Eclipse 会让你设定一个工作空间的路径,选择一个你打算存放项目的路径,然后还可以勾选默认,这样就不用每次运行都要选择一次工作空间了。

2.4 设置

  • 点击 Window - Preferences - General - Workspace, 把 Text file encoding 改为 UTF-8, 把 New text file line delimiter 改为 unix
  • Window - Preferences - Java - Formatter, 点击 Edit…, Tab policy 改为 Space only, Indentation size 和 Tab size 改为 2, 自定义 Profile name, Apply

  • Window - Preferences - XML - XML Files - Editor, 选择 Indent using spaces, Indentation size 改为 2
  • 检查 Window - Preferences - Java 里的 Compiler 和 Installed JREs, 确认 JDK 已被正确配置。

2.5 测试

最后写个简单的 Hello World 跑一下,没问题就可以了。

2.6 其他个人习惯设置

2.6.1 外置浏览器,建议用chrome方便前端调试

2.6.2 编码统一设置



统一都设置为UTF-8

2.6.3 Eclipse将换行符统一设置成Linux风格


然后Windows -> Preference -> General -> Editors -> Text Editors:

然后勾选Show whitespace characters复选框。
OK,这样结合之前对Git的设置,这样就可以保证你的代码不会因为换行符转换给你添麻烦啦。不断积累软件的使用技巧,让我们的工具变得更智能,更懂你的心。

3. 安装 Tomcat

3.1 下载 Tomcat

地址 http://tomcat.apache.org/
https://tomcat.apache.org/download-90.cgi
国内,建议用镜像站点的资源,效率要高一些。

3.2 安装 Tomcat

把压缩包的内容解压到一个你喜欢的路径,不要有中文、空格或特殊字符,路径不要深。

3.2.1系统配置-环境变量

在系统变量中添加以下变量
  (1)TOMCAT_HOME,该变量指向解压文件的路径,该目录下有lib、bin等文件夹。添加方法如下:
  点击环境变量下的“新建”,在“变量名”中填写“TOMCAT_HOME”,在“变量值”中填写解压文件的路径,
  D:\Tomcat\apache-tomcat-9.0.0.M1-windows-x64\apache-tomcat-9.0.0.M1
  (后面没有分号)然后点击“确定”,如图

(2)CATALINA_HOME,该变量的值与TOMCAT_HOME相同,设置方法同(1),如图

(3)在“系统变量”中找到Path变量,双击打开Path变量,在“变量值”的最后面添加
  %CATALINA_HOME%\bin
  (后面没有分号),如图

如果是win10,就直接添加相应的项即可。
平时的开发环境,搭建到这一步即可

3.2.2 如果要搭建成服务

(4)在“系统变量”中找到CLASSPath变量,双击打开CLASSPath变量,在“变量值”的最后面添加
  %CATALINA_HOME%\lib\servlet-api.jar
  (后面没有分号),如图

5、单击“开始”—“运行”,键入"cmd",在控制台输入service install Tomcat9,

在系统中安装Tomcat9服务项。
  然后进入控制面板—系统和安全—管理工具—服务,找到Apache Tomcat Tomcat9服务项,右击该项,点“启动”,启动该服务,如图

6、打开浏览器,地址栏输入http://localhost:8080或 http://127.0.0.1:8080
  如果出现tomcat示例主页,则表示服务器安装成功,如图

如果8080端口被占用了,可以修改tomcat的访问端口,方法如下:找到D:\Tomcat\apache-tomcat-9.0.0.M1-windows-x64\apache-tomcat-9.0.0.M1\conf目录下的server.xml文件,打开该文件,找到以下内容

注:每次需要启动tomcat服务器都要运行startup.bat文件。如果觉得麻烦可以把服务里启动类型设置为自动。但这样开机速度会慢些。

安装Apache Tomcat9.0的前提是必须安装JDK,如果没有安装JDK的用户可以点击下载jdk1.8.0_77(32/64位)

3.2.3 win10配置环境变量

这个步骤网上叫教程有很多不同版本,本人尝试很多种不行后,以下是亲测有效的。
Step1:右键 “此电脑”(如果Win10桌面没有,请百度),点击"属性",点击"高级系统设置"—>“高级”—>“环境变量”。
Step2:配置jdk的环境变量(略)
Step3:在"系统变量"里新建变量名:CATALINA_BASE,变量值:D:\JavaEE\apache-tomcat-9.0.8(此处为你的解压包路径)
Step4:在"系统变量"里新建变量名:CATALINA_HOME,变量值:D:\JavaEE\apache-tomcat-9.0.8
Step5:在"系统变量"里打开Path变量,添加变量值:%CATALINA_HOME%\lib;%CATALINA_HOME%\bin(这一步可有可无,有些电脑无需配置此步骤便可完成,因此可以先跳过Step5)
示例图如下:按顺序1,2,3执行。

按图标记顺序1,2,3配置
Step6:Win+R,输入cmd,按Enter,进入命令行界面。
进入tomcat下的bin目录(本人电脑的路径为D:\JavaEE\apache-tomcat-9.0.8\bin),执行“service.bat install” 。(附:service卸载命令:service.bat remove)

3.3 测试

打开安装路径,运行 bin - startup.bat, 然后打开一个你喜欢的浏览器,输入地址 localhost:8080
, 如果能显示经典的 Tomcat 小猫,就说明安装成功了,测试完成后记得运行 shutdown.bat 结束服务器。

不要关闭这个窗口

3.4 tomcat简单配置

打开安装路径 - conf - server.xml,在 标签里添加 URIEncoding=UTF-8,这样可以解决 get 请求的 URI 中文乱码问题,还有,如果不想用 8080 端口,直接修改 port 为你想设的端口就可以了。

3.5 在eclipse中配置

打开 Eclipse, 点击 Window - Preferences - Server - Runtime Environments, 点击 Add…, 选择 Apache Tomcat v8.5, next, 改一个喜欢的名字,选择 Tomcat 安装路径,最后 finish。



选择主界面的 Servers 标签页,点击 …create a new server…, 给服务器改个喜欢的名字,选择上一步配置的环境,finish。


双击刚创建的服务器,选择 Server Locations 为 Use Tomcat installation, 并把 Deploy path 配置为 webapps,这样每次运行 Tomcat 都会把项目发布到 Tomcat 的 webapps 目录。

点击 Window - Preferences - Web - JSP Files, Encoding 一项选择 UTF-8, 这样每次新建的 JSP 页就默认都是 UTF-8 编码了。

4. 配置和试用maven

4.1 maven版本更新

可以用eclipse已经安装好的插件版本,也可以自己更新成相应的版本。
内嵌的maven如下,版本是3.6.1,可以使用这个版本。

4.2 仓库配置文件

settings.xml文件

<?xml version="1.0" encoding="UTF-8"?><!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
--><!--| This is the configuration file for Maven. It can be specified at two levels:||  1. User Level. This settings.xml file provides configuration for a single user,|                 and is normally provided in ${user.home}/.m2/settings.xml.||                 NOTE: This location can be overridden with the CLI option:||                 -s /path/to/user/settings.xml||  2. Global Level. This settings.xml file provides configuration for all Maven|                 users on a machine (assuming they're all using the same Maven|                 installation). It's normally provided in|                 ${maven.conf}/settings.xml.||                 NOTE: This location can be overridden with the CLI option:||                 -gs /path/to/global/settings.xml|| The sections in this sample file are intended to give you a running start at| getting the most out of your Maven installation. Where appropriate, the default| values (values used when the setting is not specified) are provided.||-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><!-- localRepository| The path to the local repository maven will use to store artifacts.|| Default: ${user.home}/.m2/repository<localRepository>/path/to/local/repo</localRepository>--><!-- interactiveMode| This will determine whether maven prompts you when it needs input. If set to false,| maven will use a sensible default value, perhaps based on some other setting, for| the parameter in question.|| Default: true<interactiveMode>true</interactiveMode>--><!-- offline| Determines whether maven should attempt to connect to the network when executing a build.| This will have an effect on artifact downloads, artifact deployment, and others.|| Default: false<offline>false</offline>--><!-- pluginGroups| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.|--><pluginGroups><!-- pluginGroup| Specifies a further group identifier to use for plugin lookup.<pluginGroup>com.your.plugins</pluginGroup>--></pluginGroups><!-- proxies| This is a list of proxies which can be used on this machine to connect to the network.| Unless otherwise specified (by system property or command-line switch), the first proxy| specification in this list marked as active will be used.|--><proxies><!-- proxy| Specification for one proxy, to be used in connecting to the network.|<proxy><id>optional</id><active>true</active><protocol>http</protocol><username>proxyuser</username><password>proxypass</password><host>proxy.host.net</host><port>80</port><nonProxyHosts>local.net|some.host.com</nonProxyHosts></proxy>--></proxies><!-- servers| This is a list of authentication profiles, keyed by the server-id used within the system.| Authentication profiles can be used whenever maven must make a connection to a remote server.|--><servers><!-- server| Specifies the authentication information to use when connecting to a particular server, identified by| a unique name within the system (referred to by the 'id' attribute below).|| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are|       used together.|<server><id>deploymentRepo</id><username>repouser</username><password>repopwd</password></server>--><!-- Another sample, using keys to authenticate.<server><id>siteServer</id><privateKey>/path/to/private/key</privateKey><passphrase>optional; leave empty if not used.</passphrase></server>--></servers><!-- mirrors| This is a list of mirrors to be used in downloading artifacts from remote repositories.|| It works like this: a POM may declare a repository to use in resolving certain artifacts.| However, this repository may have problems with heavy traffic at times, so people have mirrored| it to several places.|| That repository definition will have a unique id, so we can create a mirror reference for that| repository, to be used as an alternate download site. The mirror site will be the preferred| server for that repository.|--><mirrors><!-- mirror| Specifies a repository mirror site to use instead of a given repository. The repository that| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.|<mirror><id>mirrorId</id><mirrorOf>repositoryId</mirrorOf><name>Human Readable Name for this Mirror.</name><url>http://my.repository.com/repo/path</url></mirror>--><mirror><id>alimaven</id><mirrorOf>central</mirrorOf><name>aliyun maven</name><url>http://maven.aliyun.com/nexus/content/groups/public</url></mirror><mirror> <id>CN</id> <name>OSChina Central</name> <url>http://maven.oschina.net/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror><mirror><id>repo2</id><name>Mirror from Maven Repo2</name><url>http://repo2.maven.org/maven2/</url><mirrorOf>central</mirrorOf></mirror>  </mirrors><!-- profiles| This is a list of profiles which can be activated in a variety of ways, and which can modify| the build process. Profiles provided in the settings.xml are intended to provide local machine-| specific paths and repository locations which allow the build to work in the local environment.|| For example, if you have an integration testing plugin - like cactus - that needs to know where| your Tomcat instance is installed, you can provide a variable here such that the variable is| dereferenced during the build process to configure the cactus plugin.|| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles| section of this document (settings.xml) - will be discussed later. Another way essentially| relies on the detection of a system property, either matching a particular value for the property,| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.| Finally, the list of active profiles can be specified directly from the command line.|| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact|       repositories, plugin repositories, and free-form properties to be used as configuration|       variables for plugins in the POM.||--><profiles><!-- profile| Specifies a set of introductions to the build process, to be activated using one or more of the| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>| or the command line, profiles have to have an ID that is unique.|| An encouraged best practice for profile identification is to use a consistent naming convention| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.| This will make it more intuitive to understand what the set of introduced profiles is attempting| to accomplish, particularly when you only have a list of profile id's for debug.|| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.<profile><id>jdk-1.4</id><activation><jdk>1.4</jdk></activation><repositories><repository><id>jdk14</id><name>Repository for JDK 1.4 builds</name><url>http://www.myhost.com/maven/jdk14</url><layout>default</layout><snapshotPolicy>always</snapshotPolicy></repository></repositories></profile>--><!--| Here is another profile, activated by the system property 'target-env' with a value of 'dev',| which provides a specific path to the Tomcat instance. To use this, your plugin configuration| might hypothetically look like:|| ...| <plugin>|   <groupId>org.myco.myplugins</groupId>|   <artifactId>myplugin</artifactId>||   <configuration>|     <tomcatLocation>${tomcatPath}</tomcatLocation>|   </configuration>| </plugin>| ...|| NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to|       anything, you could just leave off the <value/> inside the activation-property.|<profile><id>env-dev</id><activation><property><name>target-env</name><value>dev</value></property></activation><properties><tomcatPath>/path/to/tomcat/instance</tomcatPath></properties></profile>--></profiles><!-- activeProfiles| List of profiles that are active for all builds.|<activeProfiles><activeProfile>alwaysActiveProfile</activeProfile><activeProfile>anotherAlwaysActiveProfile</activeProfile></activeProfiles>-->
</settings>

4.3 更新eclipse里的maven设置

4.4 试建helloworld的maven项目




耐心等待一下,就可以得到对应的项目结构了,如下

设置项目,排除错误
右键项目,选择properties

更新jre版本





添加Server Runtime




4.5 更新后的maven项目结构

4.6 查看pom.xml文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>cn.edu.cuit</groupId><artifactId>j2018001001-maven01project</artifactId><packaging>war</packaging><version>0.0.1-SNAPSHOT</version><name>j2018001001-maven01project Maven Webapp</name><url>http://maven.apache.org</url><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>3.8.1</version><scope>test</scope></dependency></dependencies><build><finalName>j2018001001-maven01project</finalName></build>
</project>

4.7 查看web.xml文件

<!DOCTYPE web-app PUBLIC"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN""http://java.sun.com/dtd/web-app_2_3.dtd" ><web-app><display-name>Archetype Created Web Application</display-name>
</web-app>

4.8 查看index.jsp文件

<html>
<body>
<h2>Hello World!</h2>
</body>
</html>

右键,启动on Server项目


在浏览器中查看到结果

javaee2020-教程直播-16Windows 平台 JavaEE 基本开发环境搭建-JDK-eclipse-tomcat-maven相关推荐

  1. eclipse 关闭时progress information弹框_Spring开发环境搭建(Eclipse)

    开发环境搭建,主要包含2部分: Java安装 Eclipse安装 为易于学习,我们只安装这2个部分,对于一般开发学习也足够了.如果你有其他要安装的,酌情添加. Java安装 我们使用Java8: 下载 ...

  2. 【菠萝狗四足机器人】二次开发教程--第一章 【简介与开发环境搭建】

    Py-apple Dynamics 简介与开发环境搭建 1 简介 1.1 何为 菠萝狗 和 Py-Apple Dynamics 1.2 目前支持的功能 2 开发环境搭建 2.1 硬件的搭建 2.1 软 ...

  3. 微信公众号开发系统入门教程(公众号注册、开发环境搭建、access_token管理、Demo实现、natapp外网穿透)

    由于图片图床问题,文章部分图片无法预览,暂时把该文章迁移至简书,给大家带来麻烦,抱歉了. 感兴趣的小伙伴可参考:https://www.jianshu.com/p/cc1b1050b5b4 Autho ...

  4. Win10+Python+Django+Nginx+MySQL开发教程及实例(1)——开发环境搭建

    Win10+Python+Django+Nginx+MySQL开发教程及实例 PaulTsao 本教程共有三篇内容: 第一篇:Win10+Python+Django+Nginx+MySQL 开发环境搭 ...

  5. Django+Vue开发生鲜电商平台之2.开发环境搭建

    文章目录 一.PyCharm的安装和简单使用 二.MySQL和Navicat的安装和使用 三.Python的安装 四.虚拟环境的安装和配置 五.Vue开发环境搭建 一.PyCharm的安装和简单使用 ...

  6. vscode如何运行python新手教程_从零开始的TensorFlow+VScode开发环境搭建的步骤(图文)...

    VScode不愧是用户数量上升最快的编辑器,界面华丽(当然,需要配合各种主题插件),十分容易上手且功能强大.之前用它写C++体验十分nice,现在需要学习tensorflow,而工欲善其事必先利其器, ...

  7. 0doo-odoo-8快速开发平台pycharm下开发环境搭建

    Windows下odoo-8开发环境搭建 1.搭建准备 (1)python-2.7.X (2)pycharm-professional-2017.3.1 (3)node.js (4)postgresq ...

  8. day01--java基础编程:计算机基础知识 ,java语言概述,java开发环境搭建,eclipse概述,创建简单java项目,JDK JRE JVM的关系,java开发中的命名规范,编程风格

    1 Day01–Java开发环境+HelloWorld 1.1 计算机基础知识 资料下载网址:刘沛霞 18600949004 code.tarena.com.cn tarenacode code_20 ...

  9. 黑莓java文件怎么安装程序_黑莓开发环境搭建windows7+eclipse+BlackBerry Java Plug+JDK6...

    最近有点空闲时间,所以就学学黑莓开发,当然要开发第一步就是搭建开发环境,google了一下,有很多教程,但都是很老的了,可能是因为国内开发黑莓的人很少吧.黑莓的好处就是出了名的安全,所以有一批忠实的粉 ...

最新文章

  1. 机器学习算法学习---模型融合和提升的算法(五)
  2. CF 2B The least round way DP+Math
  3. Java NIO(一) Java NIO 概述
  4. linux命令strip
  5. 把整形数据格式化为指定长度的字符串
  6. linux多进程知识汇总
  7. 时间排序_你懂使用C ++ STL在线性时间内查找未排序数组的中位数吗
  8. mysql中如何将默认用户名root改成其他?
  9. ubuntu 14.04 将窗体button移到右边
  10. java.lang.ClassNotFoundException: javax.servlet.Filter
  11. 小米架构调整:将销售与服务部改组为中国区 王川任总裁
  12. 20165329 Java实验四 Android程序设计
  13. hpbios刷新工具_刷新:不会破产的工具
  14. SpringBoot Controller Post接口单元测试
  15. Windows错误系统配置提权之系统服务权限配置错误 (二)
  16. 使用curl命令行工具查询本地公网IP地址
  17. Opencv remap函数
  18. 什么是迭代器(Iterator)?
  19. 批发行业的各种提成方式
  20. 如何使用python下载网站上的视频

热门文章

  1. js 实现两数相加的算法
  2. 使用 JSONP、jQuery 和 Yahoo! 查询语言构建 mashup
  3. Flask——cookie的使用
  4. 如何计算近似纳什均衡_《纳什均衡与博弈论》读书笔记
  5. 汽车信息泄露法规惠及亿万人
  6. LG P990 可以删除的软件及服务
  7. 面试网易的前端工程有多难?问啥啥不会?
  8. 计算机未来的发展趋势是三网合一,三网合一技术发展趋势.pdf
  9. [zz]ERP排产详细介绍
  10. 他山之石——VBA进销存管理