国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

springboot+postgresql+docker實例

xingpingz / 1014人閱讀

摘要:查看訪問參考

postgresql
postgresql:
  image: "postgres:9.4"
  volumes_from:
    - postgresql_data
  environment:
      POSTGRES_PASSWORD: mypwd #set default password for postgres
  ports:
    - 5432:5432

postgresql_data:
  image: cogniteev/echo
  command: echo "Data Container for PostgreSQL"
  volumes:
    - /var/lib/postgresql/data

mac client

psequel

查看

postgrest
postgrest:
  build: postgrest/
  ports:
    - 3000:3000
  links:
    - postgresql
  restart: always
  environment:
    - POSTGRES_DB_NAME=postgres ##default database postgres, default user name postgres
    - POSTGRES_ADDRESS=postgresql
    - POSTGRES_PORT=5432
    - POSTGRES_PASSWORD=mypwd

訪問
http://192.168.99.100:3000/app_user
http://192.168.99.100:3000/app_user?select=username
http://192.168.99.100:3000/app_user?username=eq.hello1

springboot

pom

        
            postgresql
            postgresql
            9.1-901-1.jdbc4
        
        
            org.springframework.boot
            spring-boot-starter-data-jpa
        
        
            org.springframework.boot
            spring-boot-starter-data-rest
        

application.yml

spring:
  jpa:
    database: POSTGRESQL
    show-sql: true
    hibernate.ddl-auto: update
  database:
    driverClassName: org.postgresql.Driver
  datasource:
    platform: postgres
    url: jdbc:postgresql://postgresql:5432/postgres
    username: postgres
    password: mypwd

configuration

@Configuration
@EnableJpaRepositories(basePackages = "com.codecraft.dao")
@EnableAutoConfiguration
@EntityScan(basePackages = {"com.codecraft.domain"})
public class JpaConfiguration {
}

domain

import javax.persistence.*;

@Entity
public class AppUser {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false)
    private Long id;

    @Column(name = "username", nullable = false)
    private String username;

    public AppUser() {
    }

    public AppUser(String username) {
        this.username = username;
    }

    public AppUser(long id, String username) {
        this.id = id;
        this.username = username;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username="" + username + """ +
                "}";
    }
}

dao

import com.codecraft.domain.AppUser;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends CrudRepository {
}

controller

@RestController
@RequestMapping(value = "/product", produces = MediaType.APPLICATION_JSON_VALUE)
public class ProductUserController {

    @Autowired
    UserRepository userRepository;

    @RequestMapping(value = "/user/{username}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public AppUser create(@PathVariable String username) {
        return userRepository.save(new AppUser(username));
    }

    @RequestMapping(value = "/user", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public List findAll() {
        final List resultList = new ArrayList<>();
        final Iterable all = userRepository.findAll();
        all.forEach(new Consumer() {
            @Override
            public void accept(AppUser appUser) {
                resultList.add(appUser);
            }
        });
        return resultList;
    }
}
參考

spring-boot-postgres-sample

docker-postgrest

docker-recipes-postgrest

docker-compose-postgresql

docker-postgrest-with-postgresql

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/26605.html

相關文章

  • springboot+postgresql+docker實例

    摘要:查看訪問參考 postgresql postgresql: image: postgres:9.4 volumes_from: - postgresql_data environment: POSTGRES_PASSWORD: mypwd #set default password for postgres ports: - 5432:543...

    tabalt 評論0 收藏0
  • Docker之旅——實例: 搭建gitlab(四)

    摘要:介紹搭建與維護基于鏡像圖片來自于公社前端,用于頁面及走或協議后端服務,采用框架,通過實現后臺服務及多進程開啟服務,用于用戶上傳進行版本克隆及上傳。 gitlab介紹 GitLab搭建與維護(基于Docker鏡像sameersbn/docker-gitlab) 圖片來自于: Linux公社(https://www.linuxidc.com) showImg(https://segment...

    icyfire 評論0 收藏0
  • Java學習路線總結,搬磚工逆襲Java架構師(全網最強)

    摘要:哪吒社區技能樹打卡打卡貼函數式接口簡介領域優質創作者哪吒公眾號作者架構師奮斗者掃描主頁左側二維碼,加入群聊,一起學習一起進步歡迎點贊收藏留言前情提要無意間聽到領導們的談話,現在公司的現狀是碼農太多,但能獨立帶隊的人太少,簡而言之,不缺干 ? 哪吒社區Java技能樹打卡?【打卡貼 day2...

    Scorpion 評論0 收藏0
  • docker運行springboot實例

    摘要:中使用打包直接在的時候執行指定了的名稱為指定了鏡像名為實例文件在文件夾下面建立的內容也可以直接在中用設置定義存儲位置定義應用名稱每隔小時分割為表示以分為邊界添加依賴鏡像查看日志工程 docker-maven-plugin app org.springframework.boo...

    Darkgel 評論0 收藏0
  • docker運行springboot實例

    摘要:中使用打包直接在的時候執行指定了的名稱為指定了鏡像名為實例文件在文件夾下面建立的內容也可以直接在中用設置定義存儲位置定義應用名稱每隔小時分割為表示以分為邊界添加依賴鏡像查看日志工程 docker-maven-plugin app org.springframework.boo...

    linkFly 評論0 收藏0

發表評論

0條評論

xingpingz

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<