小编Joh*_*eer的帖子

Vue npm运行服务从随机端口开始

我正在尝试在端口8080上运行Vue,但无法使其正常工作。我刚刚使用创建了一个全新的项目,vue create .并使用运行了该项目npm run serve,这会在随机端口上启动该应用程序。

第一次尝试

无需任何其他配置即可运行npm run serve

$ npm run serve

> vue-demo@0.1.0 serve /Users/ne/projects/vue-demo
> vue-cli-service serve

 INFO  Starting development server...
Starting type checking service...
Using 1 worker with 2048MB memory limit
 98% after emitting CopyPlugin

 DONE  Compiled successfully in 4294ms                                                                                                              3:21:35 PM

No type errors found
Version: typescript 3.5.3
Time: 4267ms

  App running at:
  - Local:   http://localhost:20415/
  - Network: http://192.168.178.192:20415/

  Note that the development build is not optimized.
  To create a production …
Run Code Online (Sandbox Code Playgroud)

vue.js

18
推荐指数
1
解决办法
2260
查看次数

使用Gradle Kotlin DSL进行集成测试

我正在使用这篇博文来配置Spring Boot项目的集成测试,但我非常坚持声明源集.我也在StackOverflow上发现了这篇文章,但我想我已经进一步了.

我的项目结构是

project
|_ src
  |_ main
  | |_ kotlin
  | |_ resources
  |_ testIntegration
  | |_ kotlin
  | |_ resources
  |_ test
  | |_ kotlin
  | |_ resources
  |_ build.gradle.kts
  |_ ... other files
Run Code Online (Sandbox Code Playgroud)

build.gradle.kts

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    idea
    kotlin("jvm")
    id("org.springframework.boot") version "2.0.5.RELEASE"
    id("org.jetbrains.kotlin.plugin.spring") version "1.2.71"
}

fun DependencyHandlerScope.springBoot(module: String) = this.compile("org.springframework.boot:spring-boot-$module:2.0.5.RELEASE")
fun DependencyHandlerScope.springBootStarter(module: String) = this.springBoot("starter-$module")

dependencies {
    springBoot("devtools")

    springBootStarter("batch")
    springBootStarter("... spring boot dependencies")


    compile("... more dependencies")

    testCompile("... more …
Run Code Online (Sandbox Code Playgroud)

integration-testing gradle kotlin gradle-kotlin-dsl

10
推荐指数
2
解决办法
1972
查看次数

如何使用Python获取oauth2 access_token

对于一个项目,有人给了我这个我在Postman中用于测试目的的数据:

在Postman中,这非常有效.

身份验证网址:https://api.example.com/oauth/access_token
访问令牌网址:https
://api.example.com/access_token
客户端ID:abcde 客户端密码:12345
令牌名称:access_token
授权类型:客户端凭据

我只需要取回访问令牌.

有一次,我得到了访问令牌,我可以继续.

我已经尝试了几个Python包和一些自定义代码,但不知怎的,这个看似简单的任务开始引起真正的麻烦.

我试过一个例子:

import httplib
import base64
import urllib
import json

def getAuthToken():
    CLIENT_ID = "abcde"
    CLIENT_SECRET = "12345"
    TOKEN_URL = "https://api.example.com/oauth/access_token"

    conn = httplib.HTTPSConnection("api.example.com")

    url = "/oauth/access_token"

    params = {
        "grant_type": "client_credentials"
    }

    client = CLIENT_ID
    client_secret = CLIENT_SECRET

    authString = base64.encodestring('%s:%s' % (client, client_secret)).replace('\n', '')

    requestUrl = url + "?" + urllib.urlencode(params)

    headersMap = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization": "Basic " + authString
    }

    conn.request("POST", requestUrl, …
Run Code Online (Sandbox Code Playgroud)

python google-oauth2

9
推荐指数
2
解决办法
2万
查看次数

如何将MS Access数据库连接到Jetbrains DataGrip

我已经使用DataGrip几个星期了,我非常喜欢它.我唯一无法找到的是如何将DataGrip连接到MS Access数据库.

有人可以向我解释如何做到这一点吗?

ms-access datagrip

9
推荐指数
2
解决办法
4306
查看次数

django-storages 获取完整的 S3 url

我有几个类在 Amazon S3 中使用 django-storages

class Cache(models.Model):
    identifier = models.TextField(blank=True, null=True)
    cache_file = models.FileField(upload_to="cache")
Run Code Online (Sandbox Code Playgroud)

现在我需要获取缓存文件位置的 url。

cache = cache.objects.get(identifier=identifier)
cache_file = cache.cache_file
Run Code Online (Sandbox Code Playgroud)

缓存文件是一个FieldFile包含storage对象的对象。

在数据库中,我只能看到cache/file.json我之前保存的值。

在这种情况下,我不需要获取文件,而是获取文件所在的完整 url。
我怎么能得到这个?

python django amazon-s3

9
推荐指数
2
解决办法
4450
查看次数

在Python中使用描述符协议时如何获取属性名称?

描述符协议工作正常但我仍然有一个问题我想解决.

我有一个描述符:

class Field(object):
    def __init__(self, type_, name, value=None, required=False):
        self.type = type_
        self.name = "_" + name
        self.required = required
        self._value = value

    def __get__(self, instance, owner):
        return getattr(instance, self.name, self.value)

    def __set__(self, instance, value):
        if value:
            self._check(value)
            setattr(instance, self.name, value)
        else:
            setattr(instance, self.name, None)

    def __delete__(self, instance):
        raise AttributeError("Can't delete attribute")

    @property
    def value(self):
        return self._value

    @value.setter
    def value(self, value):
        self._value = value if value else self.type()

    @property
    def _types(self):
        raise NotImplementedError

    def _check(self, value):
        if not isinstance(value, …
Run Code Online (Sandbox Code Playgroud)

python descriptor python-descriptors

9
推荐指数
1
解决办法
7342
查看次数

有没有一种方法可以将Visual Paradigm .bak和.vux文件存储在子目录中

我已经有一段时间没有使用Visual Paradigm了,我喜欢这个工具。我唯一烦恼的是它为每个项目生成的文件数量。

我的意思是<project name>.vpp.bak_<number><project name>.vux

有没有办法将它们存储在其他地方(例如子目录)或自动将其删除?

visual-paradigm

8
推荐指数
0
解决办法
632
查看次数

Python 如何从 .whl 文件中获取版本号

由于一些自定义日志记录,我想从轮文件中获取版本号。

我当然可以只解析文件名,但我猜会有更好的方法来做到这一点。

python python-wheel

7
推荐指数
1
解决办法
1329
查看次数

Kotlin Hibernate OneToOne fetchtype.LAZY 立即运行所有查询

我正在接受培训,培训师使用 Java,我使用的是 Kotlin。到目前为止,我们在任何地方都得到了相同的结果,但在这里我无法让它发挥作用。

有2个实体类:

@Entity
data class Student(
        @Id
        @GeneratedValue
        var id: Long = 0,

        @Column(nullable = false)
        var name: String = "",

        @OneToOne()
        var passport: Passport? = null
)

@Entity
data class Passport(
        @Id
        @GeneratedValue
        var id: Long = 0,

        @Column(nullable = false)
        var number: String = ""
)
Run Code Online (Sandbox Code Playgroud)

在测试类中,我使用实体管理器进行查询。

@RunWith(SpringRunner::class)
@SpringBootTest
class StudentRepositoryTest {
    val logger = LoggerFactory.getLogger(this.javaClass)

    @Autowired
    lateinit var studentRepository: StudentRepository

    @Autowired
    lateinit var entityManager: EntityManager

    @Test
    fun retrieveStudentAndPasswordDetails() {
        val student: Student? = entityManager.find(Student::class.java, 20001L) …
Run Code Online (Sandbox Code Playgroud)

hibernate kotlin

6
推荐指数
1
解决办法
720
查看次数

如何在 Docker SQL Server 映像上运行安装脚本?

我正在尝试在 Docker SQL Server 映像上运行安装脚本

为此,我从 mssql 映像创建了一个 Dockerfile

FROM microsoft/mssql-server-linux:2017-CU8

# Create directory to place app specific files
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Copy setup scripts
COPY  entrypoint.sh \
    ./

RUN chmod +x ./entrypoint.sh

CMD /bin/bash ./entrypoint.sh
Run Code Online (Sandbox Code Playgroud)

entrypoint.sh我启动 SQL Server 时,我想运行一些安装命令。

#!/bin/bash

#start SQL Server
/opt/mssql/bin/sqlservr &

echo 'Sleeping 20 seconds before running setup script'
sleep 20s

echo 'Starting setup script'

#run the setup script to create the DB and the schema in the DB …
Run Code Online (Sandbox Code Playgroud)

sql-server docker

6
推荐指数
2
解决办法
3135
查看次数