Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- @Table(name="typedifficulte")
- public class Type {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- //@GeneratedValue(strategy = GenerationType.TABLE)
- private long idType;
- private String description;
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public long getIdType() {
- return idType;
- }
- public void setIdType(long idType) {
- this.idType = idType;
- }
- }
- import org.springframework.data.repository.CrudRepository;
- public interface TypeRepository extends CrudRepository<Type,Long> {
- Type findByDescription(String description);
- }
- import java.util.Collection;
- public interface TypeService {
- Collection<Type> getAllTypes();
- }
- import java.util.Collection;
- import javax.annotation.Resource;
- import org.apache.commons.collections4.IteratorUtils;
- import org.springframework.stereotype.Service;
- @Service(value="typeService")
- public class TypeServiceImpl implements TypeService {
- @Resource
- private TypeRepository typeRepository;
- @Override
- public Collection<Type> getAllTypes() {
- return IteratorUtils.toList(this.typeRepository.findAll().iterator());
- }
- }
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- @RestController
- public class TypeController {
- @Resource
- private TypeService typeService;
- @RequestMapping(value= "/getAllTypes", method = RequestMethod.GET)
- public Collection<Type> getAllTypes() {
- return this.typeService.getAllTypes();
- }
- }
- spring:
- profile:dev
- datasource.url:jdbc:sqlite:C:Usersuser pcDesktopPDFtestrest.db
- datasource.driverClassName:org.sqlite.JDBC
- jpa:
- hibernate:
- hbm2ddl.auto:update
- properties:
- hibernate:
- dialect:org.hibernate.dialect.SQLiteDialect
- datasource:
- url:jdbc:sqlite:C:Usersuser pcDesktopPDFtestrest.db
- username:user
- password:user
- driverClassName:org.sqlite.JDBC
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
- import org.springframework.context.annotation.ComponentScan;
- import org.springframework.context.annotation.Configuration;
- @Configuration
- @EnableAutoConfiguration
- @ComponentScan
- public class MainLauncher {
- public static void main(String[] args) {
- SpringApplication.run(MainLauncher.class, args);
- }
- }
Add Comment
Please, Sign In to add comment