pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.chipmunk</groupId> <artifactId>springbootdemo</artifactId> <packaging>war</packaging> <version>1.0.0</version> <name>springbootdemo</name>
<url>http://maven.apache.org</url> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.7.RELEASE</version> <relativePath/> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.7</java.version> <!-- <tomcat.version>7.0.69</tomcat.version> --> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> --> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <!-- <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.8</version> </dependency> --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.0.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>4.3.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>4.1.0</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.14</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.14</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> <version>3.14</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-excelant --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-excelant</artifactId> <version>3.14</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.4</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.0</version> </dependency> <!-- <dependency> <groupId>com.hope.cloud</groupId> <artifactId>cloud</artifactId> <version>1.0</version> <scope>system</scope>system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它 <systemPath>${basedir}/lib/cloud.jar</systemPath> 项目根目录下的lib文件夹下 </dependency> --> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.3.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>telemedicine</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.3.RELEASE</version> </dependency> </dependencies> </plugin> <!-- <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> --> <!-- 远程热部署 --> <!-- <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.0</version> <configuration> <url>http://localhost:8080/manager/text</url> <server>tomcat7</server> <username>tomcat</username> <password>777777</password> </configuration> </plugin> --> <!-- 自动生成mybatis代码 --> <!-- <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.5</version> <dependencies> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.5</version> </dependency> </dependencies> <executions> <execution> <id>Generate MyBatis Artifacts</id> <phase>package</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <verbose>true</verbose> <overwrite>true</overwrite> <configurationFile> src/main/resources/generator/mybatis-generator.xml </configurationFile> </configuration> </plugin> --> </plugins> </build> </project>
1.main方法运行嵌入的tomcat8
package com.chipmunk.web; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; //@Controller //@RestController /** * @SpringBootApplication=下面三个一起用 * @Configuration @EnableAutoConfiguration @ComponentScan * */ @SpringBootApplication public class SpringBootTomcatMain { public static void main(String[] args) throws Exception { SpringApplication.run(SpringBootTomcatMain.class, args); } }
2.打包后运行,配置的tomcat,需要如下类
package com.chipmunk.web; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.web.bind.annotation.RestController; @SpringBootApplication @RestController public class SpringBootTomcatWeb extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { // TODO Auto-generated method stub return builder.sources(SpringBootTomcatWeb.class); } public static void main(String[] args) { SpringApplication.run(SpringBootTomcatWeb.class, args); } }
3.热部署到远程服务器,远程tomcat服务器下tomcat-users.xml添加如下代码,与pom.xml要对应
<role rolename="admin-gui"/> <role rolename="admin-script"/> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user name="tomcat" password="777777" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui" />
---------------------------------------------------------------------------------------------------------------------------------------------
application.properties
server.port=8080 server.context-path=/springbootdemo spring.mvc.view.prefix=/WEB-INF/view/ spring.mvc.view.suffix=.jsp
HelloController
package com.chipmunk.web.controller; import java.util.HashMap; import java.util.Map; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; @Controller public class HelloController { //从 application.properties 中读取配置,如取不到默认值为Hello //@Value("${application.helloname:Hello2}") private String helloname; @RequestMapping("hello1") @ResponseBody public String hello1() { System.out.println("hello1"); return "Hello World! java"; } @RequestMapping("hello2") @ResponseBody public Map<String, Object> hello2() { System.out.println("hello2"); Map<String, Object> m = new HashMap<String, Object>(); m.put("name", "hello2"); return m; } @RequestMapping("hello3") public ModelAndView hello3() { System.out.println("hello3"); ModelAndView mav = new ModelAndView("hello"); mav.addObject("name", "hello3"); return mav; } //@PostMapping @GetMapping("hello4")//==@RequestMapping(value = "/hello3", method = RequestMethod.GET) public String hello4(Model model) { System.out.println("hello4"); model.addAttribute("name", "hello4"); return "hello"; } }
相关推荐
java运行依赖jar包
logback-classic-1.4.7.jarlogback-classic-1.4.7.jarlogback-classic-1.4.7.jarlogback-classic-1.4.7.jarlogback-classic-1.4.7.jarlogback-classic-1.4.7.jarlogback-classic-1.4.7.jarlogback-classic-1.4.7....
XmlSchema-1.4.7.jar 是一个Java库,它实现了W3C的XML Schema标准,用于处理XML Schema文档。这个版本(1.4.7)可能是该库的一个稳定版本,提供给用户免费使用。XML Schema是XML的一种规范,定义了如何验证XML文档的...
jadx - Dex to Java decompiler: Command line and GUI tools for producing Java source code from Android Dex and Apk ...jadx-gui-1.4.7-no-jre-win jadx-gui-1.4.7-with-jre-win jadx-1.4.7 jadx-1.4.7.tar.gz
《jadx-gui 1.4.7:Android逆向工程的得力助手》 在Android应用开发和安全分析领域,逆向工程是一个不可或缺的技能。它可以帮助我们理解应用程序的工作原理,查找潜在的安全漏洞,或者进行代码审计。其中,jadx-gui...
1.4.7服务端,大约是用蛤蟆吃的,水桶没试过
sqoop框架开发工具使用的jar sqoop-1.4.7.jar 手动安装到maven <groupId>org.apache.sqoop <artifactId>sqoop <version>1.4.7 </dependency>
nacos-server-1.4.7 服务注册中心
这个"mail-1.4.7.jar"是Java Mail的一个版本,主要用于处理电子邮件的发送和其他相关功能。版本号1.4.7表明这是一个较旧但稳定版本的库,包含了对SMTP、POP3和IMAP等邮件协议的支持。 Java Mail API 提供了丰富的...
此资源为基于jadx源码v1.4.7的构建版本,使用命令`./bin/jadx-gui`,即可打开jadx-gui 窗口,选择APK路径即可解析APK完成反编译过程。由于官方没有通过可执行的构建版本,所以本地构建提交资源。Github地址:...
SpringBoot 1.4.7 飞路 Lombok计划 先决条件 玛文 JDK 8 描述 添加了用于数据库迁移和版本控制的Flyway。 使用HSQL作为嵌入式数据库。 有三个应用程序配置文件( prod , dev , test ),默认配置文件是dev 。 ...
赠送jar包:mail-1.4.7.jar; 赠送原API文档:mail-1.4.7-javadoc.jar; 赠送源代码:mail-1.4.7-sources.jar; 包含翻译后的API文档:mail-1.4.7-javadoc-API文档-中文(简体)版.zip 对应Maven信息:groupId:...
标题中的"javax.mail.1.4.7.jar"指的是JavaMail的一个特定版本,即1.4.7,这是一个包含所有JavaMail核心类库的JAR文件,可以被开发者集成到他们的Java项目中。 JavaMail的核心组件主要包括以下几个部分: 1. **...
标题“macOS.Catalina.Patcher1.4.7”指的是一个专为macOS系统设计的补丁工具,主要用于帮助用户在支持High Sierra的设备上安装或升级到macOS Catalina版本10.15。这个工具的版本号是1.4.7,通常意味着它已经经过了...
虚拟机linux使用的sqoop-1.4.7版本
《M3U8批量下载器 V1.4.7版本:深入解析与应用》 M3U8批量下载器是一款专为处理M3U8格式的媒体流文件设计的工具,其V1.4.7 0903版本提供了一整套完善的解决方案,旨在帮助用户高效地下载和管理M3U8链接所指向的...
sqoop1.4.7压缩包
JavaMail API 1.4.7 是一个广泛使用的开源库,专为Java开发者设计,用于处理电子邮件相关的任务。这个版本的API提供了丰富的功能,包括发送、接收邮件,管理邮箱,处理附件,以及支持多种邮件协议如SMTP(简单邮件...
标题"wireshark-win32-1.4.7"表明这是一个针对Windows 32位系统的Wireshark版本,版本号为1.4.7。这个版本可能发布于几年前,因为Wireshark当前的版本已经更新到更高,但旧版本仍有其价值,比如用于兼容老系统或特定...
"Remote Desktop Organizer 1.4.7" 是一款专为Windows操作系统设计的远程桌面管理工具。这款软件以其小巧的体积和简洁的操作界面受到用户欢迎,它允许用户方便地管理和控制多台计算机,大大提升了远程访问的效率。 ...