Idea配置application启动Springmvc项目
配置整体工程(注意:三个编译目录重要!!!)
1.首先进入File–>Project Structure…目录下

2.设置Project Setting–>Project,此处主要配置工程的相关信息

3.设置Project Setting–>Modules,此处主要对模块下的文件进行资源标记



4.设置设置Project Setting–>Libraies,此处主要

5.设置Project Setting–>Facets

6.设置Project Setting–>Artifacts

配置application启动
1.首先编辑application配置

2.打开如下界面,在右侧进行参数设置
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qV4mPvYg-1675936017389)(C:/Users/xiaoxiao/AppData/Roaming/Typora/typora-user-images/image-20230208181639534.png)]](https://i-blog.csdnimg.cn/blog_migrate/b1bd97da3d2941fcab477eb0d03cf2c0.png)
以上Main class如果报错记得把tomcat的以下包加入进来

参数如下:
VM options:
-Dcatalina.home="D:\zixuan\source\tomcat8\tomcat8"
-Djava.endorsed.dirs="D:\zixuan\source\tomcat8\tomcat8\common\endorsed"
-Dcatalina.base="D:\zixuan\source\tomcat8\tomcat8"
-Denv.host="http://192.168.1.100:92"
-Denv.ahost="http://192.168.0.200:82/attach"
Main class:
org.apache.catalina.startup.Bootstrap
Program argument:
-config
"D:\zixuan\source\tomcat8\tomcat8\conf\devlop_future_t_server_idea.xml"
start
Working directory:
D:\zixuan\development\java\ideaproject\devlop_future
开发环境:
spring.profiles.active=dev
** 补充**


tomcat项目配置文件
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="83" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8446" maxHttpHeaderSize ="102400" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the
AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the APR/native implementation which always uses
OpenSSL for TLS.
Either JSSE or OpenSSL style configuration may be used. OpenSSL style
configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
-->
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="/" docBase="web目录全路径" reloadable="false" autoDeploy="true"/>
</Host>
</Engine>

文章详细介绍了如何在IntelliJIDEA中配置Springmvc项目,包括ProjectStructure的各个部分如Modules、Libraries、Facets和Artifacts的设置,以及如何配置application启动,特别强调了VMoptions和Mainclass的参数。此外,还提及了Tomcat的配置文件,如端口设置和SSL/TLS连接器。
1607

被折叠的 条评论
为什么被折叠?



