Created
December 19, 2013 08:10
-
-
Save daschl/8035947 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.couchbase.bootcache; | |
import com.couchbase.client.CouchbaseClient; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |
import org.springframework.context.annotation.ComponentScan; | |
import org.springframework.context.annotation.ComponentScan.Filter; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.context.annotation.Import; | |
import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration; | |
import org.springframework.data.couchbase.repository.config.EnableCouchbaseRepositories; | |
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; | |
import org.springframework.hateoas.config.EnableHypermediaSupport; | |
import org.springframework.http.MediaType; | |
import org.springframework.scheduling.annotation.EnableAsync; | |
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; | |
import org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration; | |
import org.springframework.stereotype.Service; | |
import java.net.URI; | |
import java.util.Arrays; | |
public class Bootcache { | |
public static void main(String[] args) { | |
SpringApplication.run(WebConfiguration.class, args); | |
} | |
@Configuration | |
@EnableAsync | |
@EnableAutoConfiguration | |
@EnableCouchbaseRepositories | |
@ComponentScan(includeFilters = @Filter (Service.class), useDefaultFilters = false) | |
static class ApplicationConfig extends AbstractCouchbaseConfiguration { | |
@Override | |
public CouchbaseClient couchbaseClient() throws Exception { | |
return new CouchbaseClient( | |
Arrays.asList(new URI("http://127.0.0.1:8091/pools")), | |
"default", | |
"" | |
); | |
} | |
} | |
@Configuration | |
@EnableHypermediaSupport | |
@Import ({ ApplicationConfig.class, RepositoryRestMvcConfiguration.class }) | |
@ComponentScan(excludeFilters = @Filter ({ Service.class, Configuration.class })) | |
static class WebConfiguration extends DelegatingWebMvcConfiguration { | |
@Override | |
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { | |
configurer.defaultContentType(MediaType.APPLICATION_JSON); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.couchbase.bootcache.order; | |
import org.springframework.data.annotation.Id; | |
import org.springframework.data.couchbase.core.mapping.Document; | |
import java.util.UUID; | |
@Document | |
public class Order { | |
@Id | |
private String id; | |
private String title; | |
public Order() { | |
id = UUID.randomUUID().toString(); | |
} | |
public String getId() { | |
return id; | |
} | |
public String getTitle() { | |
return title; | |
} | |
public void setTitle(String title) { | |
this.title = title; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.couchbase.bootcache.order; | |
import org.springframework.data.couchbase.repository.CouchbaseRepository; | |
public interface OrderRepository extends CouchbaseRepository<Order, String> { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment