我在一个小Django
应用程序上工作,并得到一个错误告诉我,super(type, obj): obj must be an instance or subtype of type
.我views.py
在介绍这个函数后从文件中得到它get_object_or_404
.下面views.py
提供的文件,
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse, HttpResponseRedirect
from django.views import View
from .models import URL
# function based view
def redirect_view(request, shortcode=None, *args, **kwargs):
obj = get_object_or_404(URL, shortcode=shortcode)
return HttpResponse("Hello World, the shortcode is {shortcode}".format(shortcode = obj.url))
# class based view
class ShortenerView(View):
def get(self, request, shortcode=None, *args, **kwargs):
obj = get_object_or_404(URL, shortcode=shortcode)
return HttpResponse("Hello World …
Run Code Online (Sandbox Code Playgroud) 我创建了一个Spring boot
项目,目前Spring initializer
只有初始代码.
示例代码
@SpringBootApplication
public class EcommerceApplication {
public static void main(String[] args) {
SpringApplication.run(EcommerceApplication.class, args);
}
}
@Controller
@RequestMapping(value = "/")
public class HomeController {
@GetMapping
public String index() {
return "index";
}
}
Run Code Online (Sandbox Code Playgroud)
我希望它index.html
从templates
文件夹返回页面.相反,我被重定向到该http://localhost:8080/login
地址并要求输入用户名/密码.在application.properties
文件中,我尝试使用配置,
server.port=8080
spring.application.name=Bootstrap Spring Boot
spring.thymeleaf.cache=false
spring.thymeleaf.enabled=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:bootapp;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=testuser
spring.datasource.password=testpassword
server.error.path=/error
server.error.whitelabel.enabled=false
Run Code Online (Sandbox Code Playgroud)
我尝试使用用户名testuser
和密码登录testpassword
.这没有用.
我pom.xml
在项目中使用以下内容,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> …
Run Code Online (Sandbox Code Playgroud) 我没什么经验,MySQL Workbench
需要一些帮助来找出问题.我从.MWB
GUI中的文件加载了一个新的EER图,并试图将其转换为SQL
with Forward engineer
.最初,我连接到了localhost
,当我按下时Forward engineer...
,没有任何反应.该图如下,我在Mac OS Sierra
操作系统中工作.
我在这里缺少什么?一些建议将有助于更专业的用户.
我用的是MySQL Workbench 6.3
版本,
我试图解决下面提供的Codility中的问题,
写一个函数:
class Solution { public int solution(int[] A); }
Run Code Online (Sandbox Code Playgroud)
在给定N个整数的数组A的情况下,返回A中不存在的最小正整数(大于0).
例如,给定A = [1,3,6,4,1,2],函数应返回5.
Given A = [1, 2, 3], the function should return 4.
Given A = [?1, ?3], the function should return 1.
Run Code Online (Sandbox Code Playgroud)
假使,假设:
N是[1..100,000]范围内的整数; 数组A的每个元素都是[-1,000,000..1,000,000]范围内的整数.复杂:
预期的最坏情况时间复杂度是O(N); 预期的最坏情况空间复杂度是O(N)(不计算输入参数所需的存储空间).
我写下面的解决方案,性能很低,但是,我看不到这个bug.
public static int solution(int[] A) {
Set<Integer> set = new TreeSet<>();
for (int a : A) {
set.add(a);
}
int N = set.size();
int[] C = new int[N];
int index = 0;
for (int a : set) {
C[index++] …
Run Code Online (Sandbox Code Playgroud) 我尝试设置为在Mac OS中使用来运行Hadoop brew
。下面提供了所采取的步骤,
hadoop
使用命令安装$brew install hadoop
在文件夹内,usr/local/Cellar/hadoop/3.1.0/libexec/etc/hadoop
并在文件中添加命令hadoop-env.sh
,
export HADOOP_OPTS="$HADOOP_OPTS -Djava.net.preferIPv4Stack=true -Djava.security.krb5.realm= -Djava.security.krb5.kdc="
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home"
最后,该文件如下所示:
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in …
Run Code Online (Sandbox Code Playgroud) 我想按照文档中的规定使用docker启动Confluence控制中心:
https://docs.confluence.io/platform/current/quickstart/ce-docker-quickstart.html
这是docker-compose.yaml
他们提供的文件;
---
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.5.0
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
broker:
image: confluentinc/cp-server:5.5.0
hostname: broker
container_name: broker
depends_on:
- zookeeper
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_METRIC_REPORTERS: io.confluent.metrics.reporter.ConfluentMetricsReporter
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONFLUENT_LICENSE_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
CONFLUENT_METRICS_REPORTER_BOOTSTRAP_SERVERS: broker:29092
CONFLUENT_METRICS_REPORTER_ZOOKEEPER_CONNECT: zookeeper:2181
CONFLUENT_METRICS_REPORTER_TOPIC_REPLICAS: 1
CONFLUENT_METRICS_ENABLE: 'true'
CONFLUENT_SUPPORT_CUSTOMER_ID: 'anonymous'
schema-registry:
image: confluentinc/cp-schema-registry:5.5.0
hostname: schema-registry
container_name: schema-registry
depends_on:
- zookeeper
- broker …
Run Code Online (Sandbox Code Playgroud) apache-kafka docker confluent-control-center confluent-platform apple-m1
我有一个运行Tomcat 8服务器的Java/Maven/JSP.项目结构如下,
我在pom.xml
下面提供了这个文件,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.puut.wallet</groupId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<artifactId>WalletApp</artifactId>
<name>simple-bitcoin-wallet</name>
<parent>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-parent</artifactId>
<version>RELEASE</version>
</parent>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.20</version>
</dependency>
<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
当我运行该项目时,我收到以下错误,
Error:Maven Resources Compiler: Maven project configuration required for module 'WalletApp' isn't available. Compilation of Maven …
Run Code Online (Sandbox Code Playgroud) 我使用Spring MVC RESTful
应用程序并ConstraintViolationException
坚持下去。下面提供的错误消息,
Exception in thread " STARTING" javax.validation.ConstraintViolationException: Validation failed for classes [mobi.puut.entities.WalletInfo] during persist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
ConstraintViolationImpl{interpolatedMessage='may not be null', propertyPath=id, rootBeanClass=class mobi.puut.entities.WalletInfo, messageTemplate='{javax.validation.constraints.NotNull.message}'}
ConstraintViolationImpl{interpolatedMessage='may not be null', propertyPath=currency, rootBeanClass=class mobi.puut.entities.WalletInfo, messageTemplate='{javax.validation.constraints.NotNull.message}'}
]
at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:140)
at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreInsert(BeanValidationEventListener.java:80)
at org.hibernate.action.internal.EntityIdentityInsertAction.preInsert(EntityIdentityInsertAction.java:197)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:75)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:626)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:280)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:261)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:306)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:318)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:275)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:182)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:113)
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:189)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:132)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:780)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:765) …
Run Code Online (Sandbox Code Playgroud) 我在使用Java/Spring/ Apache Cxf
网络应用程序,突然间,我做了一些显然很幼稚的更改,却收到了错误消息,
25-Aug-2017 11:48:43.036 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
log4j:WARN No appenders could be found for logger (org.apache.cxf.common.logging.LogUtils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more …
Run Code Online (Sandbox Code Playgroud) 我在 macOS M1 机器上安装了适用于 Apple Silicon 的 Goland 和 go SDK。在终端我得到 -
$ go version
go version go1.18.3 darwin/amd64
Run Code Online (Sandbox Code Playgroud)
当我尝试调试 go 应用程序时,出现以下错误 -
Debugging programs compiled with go version go1.18.3 darwin/amd64 are not supported. Use go SDK for darwin/arm64.
Run Code Online (Sandbox Code Playgroud)
如何在 MacOS 中安装 go darwin/arm64 SDK?