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
I recently reviewed some CSS-related knowledge po...
Publish Over SSH Plugin Usage Before using Publis...
Preface Hello everyone, this is the CSS wizard - ...
VMware Tools is a tool that comes with VMware vir...
In an unordered list ul>li, the symbol of an u...
When the carriage return character ( Ctrl+M ) mak...
The previous article on Docker mentioned the cons...
<br />For each of our topics, the team will ...
one: 1. Semantic tags are just HTML, there is no ...
Recently, I encountered a requirement to display ...
Table of contents 1.MySQL adds or subtracts a tim...
Preface Regarding HugePages and Oracle database o...
This article uses examples to explain the princip...
Execute the command to install the plugin postcss...
Business requirements One of the projects I have ...