@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoApplication.class);
}
}
public class Greeting {
private BigInteger id;
private String text;
public BigInteger getId() {
return id;
}
public void setId(BigInteger id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
@RestController
public class GreetingController {
private static BigInteger nextId;
private static Map<BigInteger, Greeting> greetingMap;
private static Greeting save(Greeting greeting){
if(greetingMap == null){
greetingMap = new HashMap<BigInteger, Greeting>();
nextId = BigInteger.ONE;
}
//if update....
if(greeting.getId() != null){
Greeting oldGreeting = greetingMap.get(greeting.getId());
if(oldGreeting == null){
return null;
}
greetingMap.remove(greeting.getId());
greetingMap.put(greeting.getId(), greeting);
return greeting;
}
// if create....
greeting.setId(nextId);
nextId = nextId.add(BigInteger.ONE);
greetingMap.put(greeting.getId(), greeting);
return greeting;
}
static {
Greeting g1 = new Greeting();
g1.setText("Hello word");
save(g1);
Greeting g2 = new Greeting();
g2.setText("Hello samsa");
save(g2);
}
@RequestMapping(
value="/api/greetings",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Collection<Greeting>> getGreetings(){
Collection<Greeting> greetings = greetingMap.values();
return new ResponseEntity<Collection<Greeting>>(greetings, HttpStatus.OK);
}
@RequestMapping(
value="/api/greetings/{id}",
method=RequestMethod.GET,
produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Greeting> getGreeting(@PathVariable("id") BigInteger id){
Greeting greeting = greetingMap.get(id);
if(greeting == null){
return new ResponseEntity<Greeting>(greeting, HttpStatus.NOT_FOUND);
}
return new ResponseEntity<Greeting>(greeting, HttpStatus.OK);
}
@RequestMapping(
value="/api/greetings",
method=RequestMethod.POST,
consumes=MediaType.APPLICATION_JSON_VALUE,
produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Greeting> createGreeting(@RequestBody Greeting greeting){
Greeting savedGreeting = save(greeting);
return new ResponseEntity<Greeting>(savedGreeting, HttpStatus.CREATED);
}
@RequestMapping(
value="/api/greetings/{id}",
method=RequestMethod.PUT,
consumes=MediaType.APPLICATION_JSON_VALUE,
produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Greeting> updateGreeting(@RequestBody Greeting greeting){
Greeting updatedGreeting = save(greeting);
if(updatedGreeting == null){
return new ResponseEntity<Greeting>(HttpStatus.INTERNAL_SERVER_ERROR);
}
return new ResponseEntity<Greeting>(updatedGreeting, HttpStatus.OK);
}
private static boolean delete(BigInteger id) {
Greeting deletedGreeding = greetingMap.remove(id);
if(deletedGreeding == null){
return false;
}
return true;
}
@RequestMapping(
value="/api/greetings/{id}",
method=RequestMethod.DELETE,
consumes=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Greeting> deletedGreeting(@PathVariable("id") BigInteger id, @RequestBody Greeting greeting){
boolean deleted = delete(id);
if(!deleted){
return new ResponseEntity<Greeting>(HttpStatus.INTERNAL_SERVER_ERROR);
}
return new ResponseEntity<Greeting>(HttpStatus.NO_CONTENT);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/"/>
我需要在tomcat7部署战争文件...到目前为止我所做的是1。安装Tomcat7-启动并运行。能够看到索引页2。安装apache2-up并运行.成功地将80重定向到tomcat的8080端口。所有请求都被重定向到tomcat。3.现在我需要部署战争文件。 我的战争没有被发现,也没有扩大。没有日志。。未创建“mycompany”目录。 我检查了我的server.xml下面是代码 我错过了什么吗。。
我正试图将一个。war项目部署到我的tomcat7安装中。 我使用的是Ubuntu12.04和Tomcat7。
知道如何在变化时重新部署html和jsp吗?
我有一个EC2实例在新加坡地区运行AMI:ElasticBeanstek-Tomcat7-64bit-201208231200(ami-0cdc9d5e),我正在尝试在其中部署一个war文件。我遵循的步骤是: 复制了 /opt/tomcat7/webapps文件夹中的war文件 将war文件的所有者更改为tomcat7 将war文件的权限更改为777 启动tomcat7服务器 我已经配置了安全组,
在将文件部署到Wildfly时,应将文件复制到何处? 我看不到文件在哪里: 似乎要进行爆炸式部署: 在运行期间,启用的war文件由tmp目录中的vfs分解。这些文件将在停止/重新启动/禁用时删除。 参考内容位于内容数据目录中,用于重新创建tmp文件。
我对tomcat很熟悉。我们使用服务器在eclipse中创建一个项目。xml和一些。配置文件。我们生成。战争档案。我们将这个war文件复制到我们的生产服务器webapps文件夹中,然后在webapps文件夹中生成一个同名的新文件夹。我们在那里更改生产服务器配置(在文件夹中)。 我们的一个客户想在他的JBoss服务器上部署war。我们试图通过将war复制到/standalone/deployment