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
Recently I saw an article on a public account tha...
1. delete delete is the only real way to remove a...
Preface Project release always requires packaging...
Preface: After the automation is written, it need...
Table of contents introduction scroll Element.scr...
In this article, we will use the libudev library ...
Apache Superset is a powerful BI tool that provid...
<br />I have been working in front-end for s...
When I first used docker, I didn't use docker...
<br />In the past, creating a printer-friend...
I was recently working on a project about face co...
Table of contents Overview (Loop Mode - Common) D...
When using Docker containers, it is more convenie...
The rich text component is a very commonly used c...
How long has it been since I updated my column? H...