使用IDEA进行tomcat远程debug

把程序部署到远程的服务器上,也可以使用eclipse或者IDEA进行调试。

  • tomcat远程debug
  • tomcat-manager监控
    正在tomcat的低版本中,tomcat-manager监控默认是开启的,但是从tomcat5之后的高版本默认就不开启了。这里可以把监控打开,学习一下其中可以做那些监控。
  • psi-probe监控
    psi-probe是一款更加强大的监控工具。

tomcat远程debug

用到了一个技术:jdwp
JDWP是Java Debug Wire Protocol的缩写,它定义了调试器(debugger)和被调试的Java虚拟机(target vm)之间的通信协议。这是一个标准的协议,只要服务端支持这个协议就可以进行调试,而tomcat服务器恰好支持这个协议。只需要将几个参数打开就行了。

在tomcat服务端进行配置
修改startup.sh

adog@E531:bin$ pwd
/home/adog/下载/tomcat8/apache-tomcat-8.5.45/bin
adog@E531:bin$ vi startup.sh
shift+G跳转到最后一行:
在这里插入图片描述
在最后一行的start之前加上一个参数:jpda
在这里插入图片描述

修改catalina.sh

在这里插入图片描述
搜索参数:JPDA
在这里插入图片描述
从上图可知,JPDA的默认参数是:
-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND
在这里插入图片描述
这里将第331行改为:JPDA_ADDRESS=“54321”

326 if [ "$1" = "jpda" ] ; then
327   if [ -z "$JPDA_TRANSPORT" ]; then
328     JPDA_TRANSPORT="dt_socket"
329   fi
330   if [ -z "$JPDA_ADDRESS" ]; then
331     JPDA_ADDRESS="54321"
332   fi
333   if [ -z "$JPDA_SUSPEND" ]; then
334     JPDA_SUSPEND="n"
335   fi
336   if [ -z "$JPDA_OPTS" ]; then
337     JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"
338   fi
339   CATALINA_OPTS="$JPDA_OPTS $CATALINA_OPTS"
340   shift
341 fi

其他的不需要改了。

修改tomcat进程占用的端口

adog@E531:apache-tomcat-8.5.45$ pwd
/home/adog/下载/tomcat8/apache-tomcat-8.5.45
adog@E531:apache-tomcat-8.5.45$ vi conf/server.xml
如下图,将修改对应的端口号即可。
在这里插入图片描述

启动tomcat

因为已经在系统中为tomcat配置了环境变量,所以可以直接使用bin目录下的脚本。
adog@E531:apache-tomcat-8.5.45$ startup.sh
在这里插入图片描述

查看tomcat启动信息

adog@E531:apache-tomcat-8.5.45$ tail -f ./logs/catalina.out

22-Aug-2019 21:41:05.498 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/home/adog/下载/tomcat8/apache-tomcat-8.5.45/webapps/manager] has finished in [43] ms
22-Aug-2019 21:41:05.498 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/home/adog/下载/tomcat8/apache-tomcat-8.5.45/webapps/docs]
22-Aug-2019 21:41:05.523 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/home/adog/下载/tomcat8/apache-tomcat-8.5.45/webapps/docs] has finished in [25] ms
22-Aug-2019 21:41:05.523 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/home/adog/下载/tomcat8/apache-tomcat-8.5.45/webapps/ROOT]
22-Aug-2019 21:41:05.545 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/home/adog/下载/tomcat8/apache-tomcat-8.5.45/webapps/ROOT] has finished in [22] ms
22-Aug-2019 21:41:05.546 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/home/adog/下载/tomcat8/apache-tomcat-8.5.45/webapps/host-manager]
22-Aug-2019 21:41:05.575 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/home/adog/下载/tomcat8/apache-tomcat-8.5.45/webapps/host-manager] has finished in [29] ms
22-Aug-2019 21:41:05.580 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8082"]
22-Aug-2019 21:41:05.605 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
22-Aug-2019 21:41:05.619 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 975 ms

可见,tomcat进程现在占用的是8082端口。

查看在catalina.sh配置的JDPA_ADDRESS中设置的端口

adog@E531:apache-tomcat-8.5.45$ netstat -nap | grep 54321
在这里插入图片描述
使用jps -l命令查看,有一个进程:15773 org.apache.catalina.startup.Bootstrap,这就是tomcat进程的进程,PID是15773

adog@E531:apache-tomcat-8.5.45$ jps -l
7571 com.imooc.monitor_tuning.MonitorTuningApplication
2580 org.jetbrains.idea.maven.server.RemoteMavenServer36
15222 com.intellij.idea.Main
7564 org.jetbrains.jps.cmdline.Launcher
15773 org.apache.catalina.startup.Bootstrap
16077 sun.tools.jps.Jps
编写测试的controller
package com.imooc.monitor_tuning.chapter5;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/ch5")
@RestController
public class Ch5Controller {

    @RequestMapping("/hello")
    public String hello(){
        String str = "";
        for(int i=0;i < 10;i++){
            str += i;
        }
        return str;
    }
}

打war包(为了部署到tomcat服务器上)

修改打包方式

<packaging>war</packaging>

<groupId>com.imooc</groupId>
	<artifactId>monitor_tuning</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	<name>monitor_tuning</name>
	<description>Demo project for Spring Boot</description>
修改入口的main函数

之前是:

package com.imooc.monitor_tuning;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MonitorTuningApplication {

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

现修改为:

package com.imooc.monitor_tuning;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class MonitorTuningApplication extends SpringBootServletInitializer {

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

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
		return builder.sources(MonitorTuningApplication.class);
	}
}
使用mvn命令打war包

在这里插入图片描述
出错了,原因是maven不认识某些jar包,所以在pom.xml中添加指定jar包的依赖。

		<dependency>
			<groupId>com.sun.btrace</groupId>
			<artifactId>btrace-agent</artifactId>
			<version>1.3.11</version>
			<type>jar</type>
			<scope>system</scope>
			<systemPath>/home/adog/IdeaProjects/monitor_tuning0822/src/main/resources/lib/btrace-agent.jar</systemPath>
		</dependency>

		<dependency>
			<groupId>com.sun.btrace</groupId>
			<artifactId>btrace-boot</artifactId>
			<version>1.3.11</version>
			<type>jar</type>
			<scope>system</scope>
			<systemPath>/home/adog/IdeaProjects/monitor_tuning0822/src/main/resources/lib/btrace-boot.jar</systemPath>
		</dependency>

		<dependency>
			<groupId>com.sun.btrace</groupId>
			<artifactId>btrace-client</artifactId>
			<version>1.3.11</version>
			<type>jar</type>
			<scope>system</scope>
			<systemPath>/home/adog/IdeaProjects/monitor_tuning0822/src/main/resources/lib/btrace-client.jar</systemPath>
		</dependency>

再次打war包,存在warning,但最终成功

adog@E531:monitor_tuning0822$ mvn clean package
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.imooc:monitor_tuning:war:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.sun.btrace:btrace-agent:jar should use a variable instead of a hard-coded path /home/adog/IdeaProjects/monitor_tuning0822/src/main/resources/lib/btrace-agent.jar @ line 48, column 16
[WARNING] 'dependencies.dependency.systemPath' for com.sun.btrace:btrace-boot:jar should use a variable instead of a hard-coded path /home/adog/IdeaProjects/monitor_tuning0822/src/main/resources/lib/btrace-boot.jar @ line 57, column 16
[WARNING] 'dependencies.dependency.systemPath' for com.sun.btrace:btrace-client:jar should use a variable instead of a hard-coded path /home/adog/IdeaProjects/monitor_tuning0822/src/main/resources/lib/btrace-client.jar @ line 66, column 16
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ----------------------< com.imooc:monitor_tuning >----------------------
[INFO] Building monitor_tuning 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ monitor_tuning ---
[INFO] Deleting /home/adog/IdeaProjects/monitor_tuning0822/target
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ monitor_tuning ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ monitor_tuning ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 15 source files to /home/adog/IdeaProjects/monitor_tuning0822/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ monitor_tuning ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/adog/IdeaProjects/monitor_tuning0822/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ monitor_tuning ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/adog/IdeaProjects/monitor_tuning0822/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ monitor_tuning ---
Downloading from nexus: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/surefire/surefire-junit4/2.22.2/surefire-junit4-2.22.2.pom
Downloaded from nexus: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/surefire/surefire-junit4/2.22.2/surefire-junit4-2.22.2.pom (3.1 kB at 3.1 kB/s)
Downloading from nexus: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/surefire/surefire-providers/2.22.2/surefire-providers-2.22.2.pom
Downloaded from nexus: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/surefire/surefire-providers/2.22.2/surefire-providers-2.22.2.pom (2.5 kB at 6.6 kB/s)
Downloading from nexus: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/surefire/surefire-junit4/2.22.2/surefire-junit4-2.22.2.jar
Downloaded from nexus: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/surefire/surefire-junit4/2.22.2/surefire-junit4-2.22.2.jar (85 kB at 279 kB/s)
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.imooc.monitor_tuning.MonitorTuningApplicationTests
22:23:28.827 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.imooc.monitor_tuning.MonitorTuningApplicationTests]
22:23:28.834 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
22:23:28.848 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
22:23:28.884 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.imooc.monitor_tuning.MonitorTuningApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
22:23:28.905 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.imooc.monitor_tuning.MonitorTuningApplicationTests], using SpringBootContextLoader
22:23:28.908 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]: class path resource [com/imooc/monitor_tuning/MonitorTuningApplicationTests-context.xml] does not exist
22:23:28.909 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]: class path resource [com/imooc/monitor_tuning/MonitorTuningApplicationTestsContext.groovy] does not exist
22:23:28.909 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
22:23:28.910 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]: MonitorTuningApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
22:23:28.986 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]
22:23:29.116 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/home/adog/IdeaProjects/monitor_tuning0822/target/classes/com/imooc/monitor_tuning/MonitorTuningApplication.class]
22:23:29.119 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.imooc.monitor_tuning.MonitorTuningApplication for test class com.imooc.monitor_tuning.MonitorTuningApplicationTests
22:23:29.260 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]: using defaults.
22:23:29.261 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
22:23:29.279 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/TransactionDefinition]
22:23:29.280 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
22:23:29.281 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@50eac852, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@16ec5519, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@2f7298b, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@188715b5, org.springframework.test.context.support.DirtiesContextTestExecutionListener@1ea9f6af, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@6a192cfe, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@5119fb47, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@7193666c, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@20deea7f, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@3835c46]
22:23:29.284 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]
22:23:29.285 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]
22:23:29.287 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]
22:23:29.288 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]
22:23:29.289 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]
22:23:29.289 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]
22:23:29.295 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@7fa98a66 testClass = MonitorTuningApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@15ff3e9e testClass = MonitorTuningApplicationTests, locations = '{}', classes = '{class com.imooc.monitor_tuning.MonitorTuningApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@3712b94, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@27a8c74e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@3043fe0e, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@3d921e20], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
22:23:29.296 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]
22:23:29.296 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.imooc.monitor_tuning.MonitorTuningApplicationTests]
22:23:29.318 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=-1}

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.7.RELEASE)

2019-08-22 22:23:29.673  INFO 18189 --- [           main] c.i.m.MonitorTuningApplicationTests      : Starting MonitorTuningApplicationTests on E531 with PID 18189 (started by adog in /home/adog/IdeaProjects/monitor_tuning0822)
2019-08-22 22:23:29.675  INFO 18189 --- [           main] c.i.m.MonitorTuningApplicationTests      : No active profile set, falling back to default profiles: default
2019-08-22 22:23:32.017  INFO 18189 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-08-22 22:23:32.425  INFO 18189 --- [           main] c.i.m.MonitorTuningApplicationTests      : Started MonitorTuningApplicationTests in 3.093 seconds (JVM running for 4.166)
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.282 s - in com.imooc.monitor_tuning.MonitorTuningApplicationTests
2019-08-22 22:23:32.957  INFO 18189 --- [       Thread-2] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-war-plugin:3.2.3:war (default-war) @ monitor_tuning ---
[INFO] Packaging webapp
[INFO] Assembling webapp [monitor_tuning] in [/home/adog/IdeaProjects/monitor_tuning0822/target/monitor_tuning-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Webapp assembled in [539 msecs]
[INFO] Building war: /home/adog/IdeaProjects/monitor_tuning0822/target/monitor_tuning-0.0.1-SNAPSHOT.war
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.1.7.RELEASE:repackage (repackage) @ monitor_tuning ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.134 s
[INFO] Finished at: 2019-08-22T22:23:36+08:00
[INFO] ------------------------------------------------------------------------
把war包放在tomcat的webapp目录下

在target目录下生成了war包,重命名为monitor_tuning.war
在这里插入图片描述

放在tomcat的webapps目录下

可以看出,其自动将war解压了。
在这里插入图片描述

启动tomcat
adog@E531:apache-tomcat-8.5.45$ startup.sh 
Using CATALINA_BASE:   /home/adog/下载/tomcat8/apache-tomcat-8.5.45
Using CATALINA_HOME:   /home/adog/下载/tomcat8/apache-tomcat-8.5.45
Using CATALINA_TMPDIR: /home/adog/下载/tomcat8/apache-tomcat-8.5.45/temp
Using JRE_HOME:        /home/adog/baidunetdiskdownload/jdk1.8.0_161
Using CLASSPATH:       /home/adog/下载/tomcat8/apache-tomcat-8.5.45/bin/bootstrap.jar:/home/adog/下载/tomcat8/apache-tomcat-8.5.45/bin/tomcat-juli.jar
Tomcat started.
在浏览器中进行访问

http://192.168.0.115:8082/monitor_tuning/ch5/hello ,其中monitor_tuning就是webappps目录下解压出来的文件夹,这个在访问路径中也要体现出来。
在这里插入图片描述

在IDEA中进行远程调试

在这里插入图片描述
点击"+"号,选择Remote,如下图所示。
在这里插入图片描述
在这里插入图片描述
点击绿色爬虫即可进行远程Debug
在这里插入图片描述
访问请求之后,走到断点处就暂停了
在这里插入图片描述
在这里插入图片描述
如果是普通的java进程,也想要进行远程debug,就需要将下面的代码复制,写到启动脚本中,然后就可以通过客户端(IDEA/Eclipse)来进行debug了。

-agentlib:jdwp=transport=dt_socket,address=54321,server=y,suspend=n
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值