小编Mar*_*lic的帖子

Get-AzureRmResourceGroup:术语“ Get-AzureRmResourceGroup”未被识别为cmdlet的名称

我正在尝试从PowerShell中的Azure订阅中检索资源组名称:

Get-AzureRmResourceGroup | select resourcegroupname
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

Get-AzureRmResourceGroup : The term 'Get-AzureRmResourceGroup' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling 
of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-AzureRmResourceGroup | select resourcegroupname
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-AzureRmResourceGroup:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)

我安装了PowerShell 5.0,并导入了最新的Azure模块。为什么不包括在内?

powershell azure azure-powershell

4
推荐指数
2
解决办法
6393
查看次数

Add-AzureRmAccount:Sequence不包含任何元素

我正在尝试验证脚本以通过PowerShell连接到Azure.

$username = "asdfasdf"
$password = "asdfasdf"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
Add-AzureRmAccount -Credential $cred
Select-AzureRmSubscription -SubscriptionId asdfasdf
Run Code Online (Sandbox Code Playgroud)

完整的错误消息:

Add-AzureRmAccount : Sequence contains no elements
At C:\Users\Martin\Documents\Tasks\Azure Script ARM API Syntax Conversion\Connect Azure V1.ps1:6 char:1
+ Add-AzureRmAccount -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzureRmAccount], AadAuthenticationFailedException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.AddAzureRMAccountCommand
Run Code Online (Sandbox Code Playgroud)

我在这里看到Login-AzureRmAccount无法使用PSCredential登录Azure,也许特殊字符可能会导致错误,但我尝试!在密码中转义,但没有成功.还有什么可能导致这个问题?

powershell azure azure-powershell

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

Springboot 表单验证以确保一个日期不会早于另一个日期?

遵循本指南后:https://spring.io/guides/gs/validating-form-input/,我想要进行表单验证,检查该dateTo值是否在该值之前dateFrom。如果有某种注释解决方案那就太棒了。它们作为字符串存储在我的表单提供的空模型中。

@NotNull(message="You must select a date.")
@NotBlank(message="You must select a date.")
private String dateFrom;

@Min(dateFrom)
private String dateTo;
Run Code Online (Sandbox Code Playgroud)

显然这不起作用,因为我们无法比较一个字符串是否小于另一个字符串......有其他选择吗?问题是我想在表单验证检查中直接在 UI 中提供一条消息,就像我如何检查消息是否为空或空白一样。

    // Create Request
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    String saveRequest(Principal principal, @Valid @ModelAttribute(value = "requestModel") RequestModel requestModel, BindingResult bindingResult, RedirectAttributes redirectAttributes) {
    ....
    if (bindingResult.hasErrors()) {
        // log.info("There are binding errors.");
        return "send";
    }
    ....

    // Format given date
    Date dateFrom = null;
    try {
        SimpleDateFormat formatter = new SimpleDateFormat(DateUtil.dateFormat);
        dateFrom = …
Run Code Online (Sandbox Code Playgroud)

java validation spring-mvc spring-boot

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

无法使用Sdk 23检查片段中的权限?

我正在尝试检查片段中的权限,并且无法解析'checkSelfPermission'.这里发生了什么?

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.CAMERA}, 1);
            }
        }
Run Code Online (Sandbox Code Playgroud)

java android android-permissions

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

如何使用位图将图像分享到社交媒体?

我需要从我的 RecyclerAdapter 共享一个图像,因为该图像最初并不存在,即使用适配器在 Activity 中加载。如何将位图分享到社交媒体?每次我在我的应用程序中单击共享时,它都会显示“没有应用程序可以执行此操作”。

feedItemView.setFeedSocialShareClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Share to Social Media

                ImageView imageView = (ImageView) feedItemView.findViewById(R.id.image);
                Drawable mDrawable = imageView.getDrawable();
                Bitmap mBitmap = ((BitmapDrawable)mDrawable).getBitmap();

                String path = MediaStore.Images.Media.insertImage(context.getContentResolver(),
                        mBitmap, "Design", null);

                Uri uri = Uri.parse(path);

                Intent share = new Intent(Intent.ACTION_SEND);
                share.setType("image");
                share.putExtra(Intent.EXTRA_STREAM, uri);
                share.putExtra(Intent.EXTRA_TEXT, "I found something cool!");
                context.startActivity(Intent.createChooser(share, "Share Your Design!"));
            }
        });
Run Code Online (Sandbox Code Playgroud)

java android android-contentresolver android-sharing android-recyclerview

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

比较两个String []数组并打印出不同的字符串

我有一个文件夹中的所有文件名列表和一个由开发人员手动"检查"的文件列表.我将如何比较两个数组,以便我们只打印出那些未包含在主列表中的数组.

public static void main(String[] args) throws java.lang.Exception {
        String[] list = {"my_purchases", "my_reservation_history", "my_reservations", "my_sales", "my_wallet", "notifications", "order_confirmation", "payment", "payment_methods", "pricing", "privacy", "privacy_policy", "profile_menu", "ratings", "register", "reviews", "search_listings", "search_listings_forms", "submit_listing", "submit_listing_forms", "terms_of_service", "transaction_history", "trust_verification", "unsubscribe", "user", "verify_email", "verify_shipping", "404", "account_menu", "auth", "base", "dashboard_base", "dashboard_menu", "fiveohthree", "footer", "header", "header_menu", "listings_menu", "main_searchbar", "primary_navbar"};
        String[] checked = {"404", "account_menu", "auth", "base", "dashboard_base", "dashboard_menu", "fiveohthree", "footer", "header", "header_menu", "listings_menu"};

        ArrayList<String> ar = new ArrayList<String>();

            for(int i = 0; i < checked.length; i++)
                { …
Run Code Online (Sandbox Code Playgroud)

java arrays

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

添加-AzureAccount:user_realm_discovery_failed:用户领域发现失败:无法连接到远程

我有一个尝试连接到 Azure 的英雄 PowerShell 脚本:

$username = "asdfasdf"
$password = "asdfasdf"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
Add-AzureAccount -Credential $cred
Select-AzureSubscription -SubscriptionId asdfasdf
Run Code Online (Sandbox Code Playgroud)

但我收到此错误:

Add-AzureAccount : user_realm_discovery_failed: User realm discovery failed: Unable to connect to the remote 
server
At line:6 char:1
+ Add-AzureAccount -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzureAccount], AadAuthenticationFailedException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount
Run Code Online (Sandbox Code Playgroud)

我的用户绝对是 Azure 目录的共同管理员。是否必须使用代理才能与 Azure 通信?

powershell azure

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

ENUM的Thymeleaf下拉菜单:EL1043E:意外令牌。预期为'rparen()),但为'lparen(()'

尝试用Thymeleaf ENUM填充HTML的下拉菜单时出现错误。我不确定是什么问题:

<select>
<option th:each="complexity : ${T(cz.test.sc.entity.common.Complexity.values()}"
        th:value="${complexity}"
        th:text="${complexity}">
</option>
</select>
Run Code Online (Sandbox Code Playgroud)

枚举:

public enum Complexity {
    VERY_SIMPLE(1) {
        public String toString() {
            return "1. Very Simple";
        }
    },
    SIMPLE(2) {
        public String toString() {
            return "2. Simple";
        }
    },
    MEDIUM(3) {
        public String toString() {
            return "3. Medium";
        }
    },
    COMPLEX(4) {
        public String toString() {
            return "4. Complex";
        }
    },
    VERY_COMPLEX(5) {
        public String toString() {
            return "5. Very Complex";
        }
    };

    Complexity(int id) {
        EnumUtil.setEnumOrdinal(this, id);
    }
} …
Run Code Online (Sandbox Code Playgroud)

java enums spring spring-el thymeleaf

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

在Thymeleaf中,如何基于当前模型对象为HTML选择器选择th:selected值?

从下面的控制器,我将资源值列表传递serviceRequestList到模型中,即绑定到HTML选择器(下拉菜单)。但是,此页面上存在单个对象ServiceRequestDO。我希望选择器默认为当前对象的值,这样在保存更改时,用户不必记住最初的所有值是什么,然后重置它们。有道理吧?是否存在一些Thymeleaf条件,它将某个字段的当前模型对象的值与应默认选择的选择器相匹配?

ServiceRequestController:

@RequestMapping(value = "edit/{id}", method = RequestMethod.GET)
    String GetEditDetails(Model model, Principal principal, @PathVariable("id") Long id, @Valid @ModelAttribute(value = "requestModel") RequestModel requestModel, BindingResult bindingResult, RedirectAttributes redirectAttributes)
    {
        UserDO currentUser = userRepository.findOneByInitialName(principal.getName());

        // Redirect to index if user is not a manager
        if (currentUser.getRole() != Role.MANAGER) {
            return "redirect:/index";
        }

        ServiceRequestDO service = serviceRequestRepository.findById(id);
        model.addAttribute("service", service);

        model.addAttribute("currentUser", currentUser);
        model.addAttribute("requestModel", new RequestModel());

        List<ServiceRequestTypeResource> serviceRequestList = serviceRequestTypeRepository.findAll();
        List<SubServiceRequestTypeResource> subServiceRequestTypeList = subServiceRequestTypeRepository.findAll();
        List<ServiceLineTypeResource> serviceLineList = serviceLineRepository.findAll();
        List<ProductTypeResource> productList = productRepository.findAll(); …
Run Code Online (Sandbox Code Playgroud)

html java spring-mvc thymeleaf spring-boot

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

我不能在Springboot-Kotlin中排除MongoAutoConfiguration(MongoSocketOpenException)

在此输入图像描述

我试图排除MongoAutoConfiguration时遇到MongoSocketOpenException.我正在尝试连接到远程MongoDB.考虑到我在Kotlin工作,@ EnableAutoConfiguration语法是否正确?

例外:

com.mongodb.MongoSocketOpenException: Exception opening socket
        at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongo-java-driver-3.4.2.jar:na]
        at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115) ~[mongo-java-driver-3.4.2.
jar:na]
        at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) ~[mongo-java-
driver-3.4.2.jar:na]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_20]
Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_20]
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_20]
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) ~[na:1.8.0_20]
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_20]
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_20]
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_20]
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_20]
        at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_20]
        at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:57) ~[mongo-java-driver-3.4.2.jar:na]

        at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongo-java-driver-3.4.2.jar:na]
        ... 3 common frames omitted
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc mongodb kotlin spring-boot

3
推荐指数
2
解决办法
1269
查看次数