小编Mai*_*sad的帖子

Spring Boot 无法自动装配 @ConfigurationProperties

这是我的FileStorageProperties课:

 @Data
 @ConfigurationProperties(prefix = "file")
 public class FileStorageProperties {
       private String uploadDir;
 }
Run Code Online (Sandbox Code Playgroud)

这让我说:未通过 @enableconfigurationproperties 注册或标记为 spring 组件

这是我的FileStorageService

@Service
public class FileStorageService {

private final Path fileStorageLocation;

@Autowired
public FileStorageService(FileStorageProperties fileStorageProperties) {
    this.fileStorageLocation = Paths.get(fileStorageProperties.getUploadDir())
            .toAbsolutePath().normalize();

    try {
        Files.createDirectories(this.fileStorageLocation);
    } catch (Exception ex) {
        throw new FileStorageException("Could not create the directory where the uploaded files will be stored.", ex);
    }
}

public String storeFile(MultipartFile file) {
    // Normalize file name
    String fileName = …
Run Code Online (Sandbox Code Playgroud)

java spring bean-validation spring-boot spring-restcontroller

13
推荐指数
1
解决办法
1万
查看次数

我在使用全局工作线程和异步时遇到 PDF.JS 错误

我的 pdfjs 脚本有问题。

我第一次尝试,收到以下消息:

已弃用的 API 用法:未指定“GlobalWorkerOptions.workerSrc”。未捕获的异常:未定义

所以我遵循github上的文档:https://github.com/mozilla/pdf.js/issues/10478

现在我收到此消息:SyntaxError:await仅在异步函数和异步生成器中有效


<div class="d-flex justify-content-center">
    <canvas id="pdf-render">

    </canvas>
</div>

    <div class="pdfcontroller d-flex justify-content-around">
        <button class="btn btn-primary" id="prev-page">
            prev page
        </button>
        <p class="page-info"> 1 / 2</p>
        <button class="btn btn-primary" id="next-page">
            Next page
        </button>
    </div>
    <script
            src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.4.456/pdf.min.js">
    </script>
    <script>
        const url = 'filesample.pdf'

        let pdfDoc = null;
        pageNum = 1;
        pageIsrendreing = false;

        pageNumisPending = null;

        const scale = 1.5,
            canvas = document.querySelector('#pdf-render'),

            ctx = canvas.getContext('2d');


        // Render the page

        const renderPage = num …
Run Code Online (Sandbox Code Playgroud)

javascript twig pdf.js

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

kotlin flow onEach 没有被触发

我正在尝试使用 来存储价值DataStore


class BasicDataStore(context: Context) :
    PrefsDataStore(
        context,
        PREF_FILE_BASIC
    ),
    BasicImpl {

    override val serviceRunning: Flow<Boolean>
        get() = dataStore.data.map { preferences ->
            preferences[SERVICE_RUNNING_KEY] ?: false
        }

    override suspend fun setServiceRunningToStore(serviceRunning: Boolean) {
        dataStore.edit { preferences ->
            preferences[SERVICE_RUNNING_KEY] = serviceRunning
        }
    }

    companion object {
        private const val PREF_FILE_BASIC = "basic_preference"
        private val SERVICE_RUNNING_KEY = booleanPreferencesKey("service_running")
    }
}

@Singleton
interface BasicImpl {
    val serviceRunning: Flow<Boolean>
    suspend fun setServiceRunningToStore(serviceRunning: Boolean)
}
Run Code Online (Sandbox Code Playgroud)

在 a 中Service,尝试监视该值,以下是相应的代码:

private fun monitorNotificationService() { …
Run Code Online (Sandbox Code Playgroud)

datastore coroutine kotlin kotlin-coroutines kotlin-flow

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

安卓 | 科特林 | Flow - 无法转换为 kotlinx.coroutines.flow.StateFlow

我试图让自己熟悉DataStore,所以在我当前的项目中,我尝试使用它。

在我的依赖中。我已经添加 :

    implementation "androidx.datastore:datastore-preferences:1.0.0-alpha06"
Run Code Online (Sandbox Code Playgroud)

然后我创建了这个类来处理数据存储:

class BasicDataStore(context: Context) :
    PrefsDataStore(
        context,
        PREF_FILE_BASIC
    ),
    BasicImpl {
    override val serviceRunning: Flow<Boolean>
        get() = dataStore.data.map { preferences ->
            preferences[SERVICE_RUNNING_KEY] ?: false
        }
    override suspend fun setServiceRunningToStore(serviceRunning: Boolean) {
        dataStore.edit { preferences ->
            preferences[SERVICE_RUNNING_KEY] = serviceRunning
        }
    }
    companion object {
        private const val PREF_FILE_BASIC = "basic_preference"
        private val SERVICE_RUNNING_KEY = booleanPreferencesKey("service_running")
    }
}
@Singleton
interface BasicImpl {
    val serviceRunning: Flow<Boolean>
    suspend fun setServiceRunningToStore(serviceRunning: Boolean)
}
Run Code Online (Sandbox Code Playgroud)

在我的视图模型中,我尝试使用该值,如下所示:

class MainViewModel(application: Application) : …
Run Code Online (Sandbox Code Playgroud)

android android-lifecycle android-architecture-components kotlin-coroutines android-jetpack-datastore

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

Geopandas 减少图例大小(并删除地图下方的空白区域)

我想知道如何更改 Geopandas 自动生成的图例。大多数情况下,我想减小它的大小,因为它在生成的图像上非常大。图例似乎占用了所有可用空间。

附加问题,您知道如何删除地图下方的空白区域吗?我试过

pad_inches = 0, bbox_inches='tight' 
Run Code Online (Sandbox Code Playgroud)

但我在地图下方还有一个空白区域。

在此处输入图片说明

谢谢你的帮助。

legend legend-properties geopandas

5
推荐指数
2
解决办法
4040
查看次数

如何在 Unity 中的网格中执行布尔运算?

我有Cube模型和Cylinder模型。我想打一个洞里面CubeCylinder,我该怎么做呢?

我有这两个模型:

在此处输入图片说明

我想做这个:

在此处输入图片说明

csg unity-game-engine

5
推荐指数
1
解决办法
8860
查看次数

antd:如何在Dragger Upload右侧显示fileuploadlist

我试图将文件上传列表显示在上传拖动器元素的右侧,因为屏幕上的空间在垂直方向上是有限的。作为参考,这是我正在尝试做的事情的图像示例:

示例图片

但是,无论我做什么,生成的文件上传列表始终显示在拖动器下方。即使我指定“display: inline-block”作为样式。由于antd框架的原因,上传列表似乎是动态生成的,我无法修改其位置。如果可以使用 antd 生成的上传列表,任何人都可以了解任何见解吗?

import React from 'react';
import { Upload, Icon, message, Typography, Button } from 'antd';

const { Dragger } = Upload;

export interface projectFilesUploadFormProps {
    handleUpdateAndNext(updateProjectDetails: () => void): void;
    handleBack(): void;

}


const draggerProps = {
    name: 'file',
    multiple: true,
    action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
    onChange(info: { file: { status?: any; name?: any; }; fileList: any; }) {
      const { status } = info.file;
      if (status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (status === 'done') {
        message.success(`${info.file.name} …
Run Code Online (Sandbox Code Playgroud)

typescript antd

5
推荐指数
1
解决办法
8470
查看次数

如何允许Spring Boot中启用CORS的所有请求?

在我的Spring boot应用程序中,目前我有这个类:

@SpringBootApplication
public class TestApplication {
   public static void main(String[] args) {
      SpringApplication.run(TestApplication.class, args);
   }
   @Bean
   public WebMvcConfigurer corsConfigurer() {
      return new WebMvcConfigurerAdapter() {
         @Override
         public void addCorsMappings(CorsRegistry registry) {
            registry.addMapping("/user").allowedOrigins("http://localhost:3000");
         }
      };
   }
}
Run Code Online (Sandbox Code Playgroud)

它只允许我访问或写入http://localhost:3000,但我希望这个休息方法可以被所有东西访问,比如http://localhost:1000http://localhost:9999或任何网站。

我怎样才能启用它?

spring spring-boot

4
推荐指数
1
解决办法
1万
查看次数

PyCharm如何在没有JRE的情况下运行,尽管它是使用Swing制作的?

PyCharm是使用Java-Swing制作的吗?

如果是,那么它如何在尚未设置JDK或JRE的PC上运行?

java pycharm

3
推荐指数
1
解决办法
95
查看次数

InvalidDataAccessApiUsageException: 没有枚举常量

我有一个 Role 枚举,如下所示:

public enum Role{
    admin('a'),
    member('m'),
    pending('p');
    char role;
    Role(char a) {
        this.role = a;
    }
    public char getRole() {
        return role;
    }
    public static Role getByRole(char role) {
        return Arrays.stream(Role.values())
                .filter(Role -> Role.getRole() == role)
                .findFirst()
                .orElse(Role.pending);
    }
}
Run Code Online (Sandbox Code Playgroud)

为了支持转换,我创建了一个名为 RoleConverter 的类:

@Converter
public class RoleConverter implements AttributeConverter<Role, Character> {
    @Override
    public Character convertToDatabaseColumn(Role Role) {
        return Role.getRole();
    }
    @Override
    public Role convertToEntityAttribute(Character dbData) {
        System.out.println(dbData);
        return Role.getByRole(dbData);
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的 Target 对象中,我添加了适当的注释:

    @Convert(converter = RoleConverter.class)
    @Enumerated(EnumType.STRING) …
Run Code Online (Sandbox Code Playgroud)

spring jpa h2 spring-data-jpa spring-boot

3
推荐指数
1
解决办法
4440
查看次数