The deployment of a piece simple project turned out to encounter so much?

demand:

  PHP server has been around for many projects, and now my new javaWeb project to be deployed to Tomcat inside the same server to the newly installed, and can be accessed by the domain name.

ready:

  1. Install jdk, tomcat, mysql (regardless of the windows system, or a linux system, it is recommended to use the control panel pagoda, visualization, excellent, very nice !!!)

  2.Springboot project to fight the war package, put in Tomcat

Question 1:

  Springboot project in the end with embedded tomcat start, or use an external?

1 resolved:

I'm going to read the Spring Boot: Built-in and external start tomcat tomcat deployment summary article, first with embedded hit the jar package, put linux system, anyway, I can not start life and death, reported that a bunch of yo wrong, I do not I clearly jar package is not a problem

Resolute decision to use external tomcat way to fight the war package, this method is good depends I used -> then open out.

Question 2:

  Springboot or need to comment out the embedded tomcat?

Solve 2:

  I started shining SpringBoot use IDEA set of external Tomcat start ,

springboot how to use external tomcat container , modify these articles:

1. First modify pom file:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-tomcat</artifactId>
  <scope>provided</scope>
</dependency>

  Changed

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <!-- 移除嵌入式tomcat插件 -->
	<exclusions>
	  <exclusion>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-tomcat</artifactId>
	  </exclusion>
	</exclusions>
</dependency>
<dependency>
	<groupId>javax.servlet</groupId>
	<artifactId>javax.servlet-api</artifactId>
	<version>3.1.0</version>
	<scope>provided</scope>
</dependency>

  javax.servlet-api also need to add, otherwise the session will complain

2. Modify the startup class Springboot

  • Deployment outside of the container, then you can not rely on the Application of the main function, but rather in a manner similar to web.xml configuration file to start the Spring application context, then we need to start classes in the inheritance SpringBootServletInitializer configure and implement methods:

@SpringBootApplication
@ServletComponentScan
@ComponentScan(basePackages = {"com.example.controller", "com.example.service"})
@MapperScan(basePackages = {"com.example.dao"})
public class SpringbootdemoApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringbootdemoApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(SpringbootdemoApplication.class, args);
    }
}

 

Later I found out, do not comment embedded tomcat also have nothing, then it is no longer the tube, directly to fight the war package, to throw inside tomcat, ha ha ha ha!

However, be aware that there is such a thing!

Question 3:

Because I wrote the project is Springboot use, Springboot embedded Tomcat, so access to local start, no need to add the project name on it

But into the external Tomcat start, must be added to the project name, Tomcat to know what you want to access a project, the solution is as follows:

Solve 3:

Inside the Tomcat server.xml file need to add a <Context> tag, which write the project name in the <Host> tag

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
    <Context path="" docBase="项目名" debug="0" reloadable="true" caseSensitive="true" />
</Host>
Please fill in the project name docBase

Question 4:

Because the server which already has other PHP projects, and with 80 ports Apache environment to start, but I added a new tomcat 8080 port, if the project starts with the domain name and port number becomes very low, but the port has been occupied 80 , but can not close it, how to do this?

Solve 4:

1. nginx can be achieved , drawback: if before installing nginx, there will be a server other items, you will need to delete the site, installed the re-establishment of the site, fear not kidding me?

2. set up a site under IIS? This approach is just to write a html, I tried for a long time, do not know where this htm on this, so I did not succeed.

3. Finally still use this method: the Apache Tomcat and the common port 80

In fact, this method is a surface meaning, the meaning is the reverse proxy.

 

 

Guess you like

Origin www.cnblogs.com/HelloXTF/p/11983932.html