/test-api/products <profiles>
<!-- Used to run the app on the local machine as standalone application -->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</profile>
<!-- Used to run the app on SAP Cloud Platform in a Tomcat 8 -->
<profile>
<id>prod</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<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>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
</exclusion>
<!-- Exclude logback and SpringBoot logging, otherwise the app won't start on SAP Cloud Platform -->
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles> * Sample RESTful application
*/
@SpringBootApplication
@ComponentScan("com.ecosio")
public class SpringRestApplication extends SpringBootServletInitializer {
//Make sure that everything for .war deployment is there
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringRestApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringRestApplication.class, args);
}
}/**
* Sample product structure. Note that getters and setter are auto-generated by Lombok
*/
@Data
@Builder
public class Product {
private String id;
private String name;
private BigDecimal price;
}/**
* Serves a list of sample products
*/
@RestController
@RequestMapping("/test-api")
public class ProductController {
private List<Product> products = new LinkedList<>();
@RequestMapping(method = RequestMethod.GET, value = "/products")
public List<Product> getProducts () {
return products;
}
@PostConstruct
private void loadDummyData() {
products.add(Product.builder().id("1").name("Apple").price(new BigDecimal("0.7")).build());
products.add(Product.builder().id("2").name("Pear").price(new BigDecimal("0.8")).build());
products.add(Product.builder().id("3").name("Orange").price(new BigDecimal("0.4")).build());
}
}mvn spring-boot:runmvn -P prod clean package



https://samplerestprodupXXXtria.hanatrial.ondemand.com/sample-rest-product-service/test-api/products
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 29 | |
| 25 | |
| 24 | |
| 19 | |
| 14 | |
| 13 | |
| 12 | |
| 11 | |
| 11 | |
| 11 |