one. Remote deployment using tomcat 1.1 Problems encountered: A third-party jar package needs to be referenced in the project. When using mvn to package the project, an error message will be reported: <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <username>admin</username> <password>123456</password> <url>http://47.102.123.186:8095/manager/text</url> <server>tomcatServer</server> //To be consistent with the id in the server<update>true</update> <path>/zw</path>//project name</configuration> </plugin> (2) Configure the tomcat-users.xml configuration file in the tomcat directory: <role rolename="admin-gui"/> <role rolename="manager-gui"/> // Allow access to the HTML interface (that is, the URL path is /manager/html/*) <role rolename="manager-script"/> // Allow access to the plain text interface (that is, the URL path is /manager/text/*) <user username="admin" password="123456" roles="admin-gui,manager-gui,manager-script"/> //Notice! You can add multiple roles to this user. For remote deployment, at least this role is required: manager-script. You can also enable manager-gui for visual management. (3) Configure Maven's setting.xml file under the servers tag: <server> <id>tomcatServer</id> <username>admin</username> <password>123456</password> </server> (4) Use the command: mvn tomcat7:deploy two. Specific steps to configure database connection configuration using tomcat configuration file You need to configure server.xml, context.xml, and web.xml in the conf directory of tomcat. `<Resource name="jdbc/DataSource" auth="Container" type="javax.sql.DataSource" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://192.168.0.1;databaseName=xydi" username="sa" password="sa" maxActive="20" //Maximum number of connections maxIdle="10" maxWait="-1"/>`//The longest waiting time Configuration under Context.xml: <ResourceLink name="jdbc/DataSource" global="jdbc/DataSource" type="javax.sql.DataSource"/>// Import the configuration information of server.xml Configuration under Web.xml: <resource-ref> <res-ref-name>jdbc/DataSource</res-ref-name>//Consistent with the name of the resource <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>` If you use the Spring framework: <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/jdbc/DataSource"/> <property name="expectedType" value="javax.sql.DataSource"/> </bean> Without using the Spring framework: Connection con = null; Context c = new InitialContext(); DataSource ds = (DataSource) c.lookup("java:/comp/env/jdbc/DataSource"); //The project name should correspond to that in context.xml con = ds.getConnection(); Summarize This is the end of this article about remote deployment of Maven projects and configuring database connections using Tomcat. For more information about remote deployment of Tomcat database connections for Maven projects, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MySQL 8.0.20 winx64 installation and configuration method graphic tutorial
>>: Vue implements three-dimensional column chart based on echarts
In the process of team development, it is essenti...
Table of contents background Problem Description ...
The importance of data consistency and integrity ...
This article mainly introduces the binary type op...
After reading some articles, I finally figured ou...
As users become more privacy-conscious and take m...
Check the top 100 highest scores in game history ...
Table of contents url module 1.parse method 2. fo...
0. System requirements CPU I5-10400F or above Mem...
Conclusion: In a multithreaded environment, if on...
Intersection Selector The intersection selector i...
⑴ Content determines form. First enrich the conten...
This article describes the usage of MySQL stored ...
Table of contents Preface React Functional Compon...
Assume there are two Linux servers A and B, and w...