JavaWEB大神成长篇:企业级 Maven 私服配置与 Tomcat 避坑指南(第一期)
JavaEE是企业级Java开发平台,由Sun公司创建、Oracle维护,包含13项技术规范如Servlet、JSP等。JavaEE应用服务器(如Weblogic、Tomcat)是其具体实现。Maven是Apache提供的Java项目管理工具,通过POM模型标准化项目结构、构建流程和依赖管理。Maven通过本地/远程/中央三级仓库机制管理jar包,安装需配置环境变量和settings.xml文件设
·
JavaEE简介
-
概述
-
JavaEE(Java Enterprise Edition),Java企业版,是一个用于企业级web开发平台
-
最早由Sun公司定制并发布,后由Oracle负责维护
-
JavaEE平台规范了在开发企业级web应用中的技术标准

-
在JavaEE平台共包含了13个技术规范(随着JavaEE版本的变化所包含的技术点的数量会有增多)

-
JavaEE版本变化
年份 版本 对 JDK 的支持 Servlet 版本 JSP 版本 1999年 12月1.2 1.1 and later 2.2 1.1 2001年 9月1.3 1.3 and later 2.3 1.2 2003年 11月1.4 1.4 and later 2.4 2.0 2006年 5月5.0 5 and later 2.5 2.1 2009年 10月6.0 6 and later 3.0 2.2 2013年 6月7.0 7 and later 3.1 2.3 2017年 8月8.0 8 and later 4.0 2.3 -
JavaEE阶段需要学习的核心技能
-
-
JavaEE应用服务器(JavaEE Application Server)
-
Web容器(Web Server)
Maven的安装和使用
-
Maven概述
-
Maven仓库访问流程
-
Maven安装

-
Maven安装后:

-
配置环境变量
-
查询是否配置成功

-
配置本地仓库
-
进入
Maven安装目录,然后进入conf文件夹,在进入settings.xml配置文件(推荐使用Notepad++打开)

<?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 at http://www.apache.org/licenses/LICENSE-2.0 Unless 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> --> <!--本地仓库路径--> <localRepository>D:\soft\安装包\Maven\apache-maven-3.6.1-bin\apache-maven-3.6.1\mvn_resp</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> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</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>
-
-
-
Maven常用命令
-
powershell和cmd区别是什么
-
Maven生命周期
-
概念
-
生命周期(Life Cycle)的概念应用很广泛,特别是在政治、经济、环境、技术、社会等诸多领域经常出现,其基本涵义可以通俗地理解为“从摇篮到坟墓”(Cradle-to-Grave)的整个过程
-
在Maven中,生命周期就是用来描述Maven构建的项目所经历的的过程(就像人的儿童时期……老年时期),明确项目所处的阶段。Maven中常见的生命周期示意图:

阶段 处理 描述 验证 validate验证项目 验证项目是否正确且所有必须信息是可用的编译 compile执行编译 源代码编译在此阶段完成测试 Test测试 使用适当的单元测试框架(例如JUnit)运行测试包装 package打包 创建JAR/WAR包如在 pom.xml 中定义提及的包检查 verify检查 对集成测试的结果进行检查,以保证质量达标安装 install安装 安装打包的项目到本地仓库,以供其他项目使用部署 deploy部署 拷贝最终的工程包到远程仓库中,以共享给其他开发人员和工程 -
-
Maven对项目构建的生命周期划分为3套:
-
备注:
-
-
IDEA中Maven的使用
-
知识点须知:Maven中的坐标
-
Maven项目的创建
-
Maven项目的导入:




-
使用Maven导入jar包
-
使用Maven是直接通过设置pom.xml配置文件进行jar包导入,而不需要手动去网上搜索jar包然后进行导入,方便、快捷(也可以使用它来导入插件,方法是一样的)
<?xml version="1.0" encoding="UTF-8"?> <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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!--项目的坐标信息--> <groupId>com.hhxy.maven</groupId><!--项目组织名--> <artifactId>day2_maven_demo</artifactId><!--项目模块名--> <version>1.0-SNAPSHOT</version><!--项目版本号--> <!--JDK的版本--> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> </properties> <!--使用坐标导入jar包--> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.27</version> </dependency> </dependencies> </project>-
备注:
-
导入jar包的语句可以不写,直接去这个网址进行复制:Maven Repository: Search/Browse/Explore -
导入jar包的代码写好后要进行刷新操作(或者Ctrl+S也可以) -
也可以使用Alt+Insert快捷键,然后按Dependency进行导入(但是只能导入本地仓库中有的) -
IDE(Integrated Development Environment )就是集成开发环境,常见的有:Eclipse、IDEA -
依赖管理就是管理项目中所依赖的第三方资源,比如jar包、插件…… -
本地仓库(Local Repository):自己计算机上的一个文件夹 -
远程仓库(Remote Repository):一般由公司团队搭建的私有仓库 -
中央仓库(Central Repository):由Maven团队维护的全球唯一的仓库
-
-
-
-
Tomcat安装启动
Tomcat结构介绍
Tomcat部署项目
Tomcat常见配置
-
Tomcat配置文件介绍
-
context.xml
-
web.xml
-
server.xml
-
tomcat-users.xml
-
解决控制台乱码
-
修改Tomcat监听端口
<Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443"/> // 80是http协议默认的端口号: 在http:1.1中, 如果不写端口号那么默认端口号就是80 -
配置Tomcat并发数
-
Tomcat 的最大并发数是可以配置的,实际运用中,最大并发数与硬件性能和 CPU 数量都有很大关系的,更好的硬件,更多的处理器都会使 Tomcat 支持更多的并发
-
这个并发能力还与应用的逻辑密切相关,如果逻辑很复杂需要大量的计算,那并发能力势必会下降,如果每个请求都含有很多的数据库操作,那么对于数据库的性能也是非常高的
-
对于单台数据库服务器来说,允许客户端的连接数量是有限制的,并发能力问题涉及整个系统架构和业务逻辑、系统环境不同、Tomcat版本不同、JDK版本不同、以及修改的设定参数不同,并发量的差异还是满大的,并发数设置参数有如下几个
-
maxThreads="1000" -
minSpareThreads="100" -
maxSpareThreads="500" -
acceptCount="700"<Connector port="8080" protocol="HTTP/1.1" minSpareThreads="100" maxSpareThreads="500" maxThreads="1000" acceptCount="700" connectionTimeout="20000" redirectPort="8443" />
-
-
配置Tomcat Manager
-
配置用户及角色
<role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <role rolename="admin-gui"/> <role rolename="admin-script"/> <user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
openEuler 是由开放原子开源基金会孵化的全场景开源操作系统项目,面向数字基础设施四大核心场景(服务器、云计算、边缘计算、嵌入式),全面支持 ARM、x86、RISC-V、loongArch、PowerPC、SW-64 等多样性计算架构
更多推荐




























所有评论(0)