小编kry*_*ger的帖子

无法执行Java命令.访问被拒绝.(0x5的)

在启动StartSonar.bat时,我收到以下错误,我wrapper.java.command=C:/Program Files/Java/jdk1.8.0_121/bin在wrapper.config文件中添加了.

Critical error: wait for JVM process failed
--> Wrapper Started as Console
Launching a JVM...
Unable to execute Java command.  Access is denied. (0x5)

Advice:
Access denied errors when attempting to launch the Java process are
usually caused by strict access permissions assigned to the directory
in which Java is installed.
Run Code Online (Sandbox Code Playgroud)

java

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

Spring框架升级到5

我正在尝试将Spring 4.0.1.RELEASE升级到最新的Spring版本5.0.6.RELEASE.在我的pom.xml中更改版本后,它显示错误

org.springframework.beans.factory.BeanDefinitionStoreException:从ServletContext资源解析XML文档的意外异常[/WEB-INF/spring/appServlet/servlet-context.xml]; 嵌套异常是java.lang.NoSuchMethodError:org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.getEnvironment()Lorg/springframework/core/env/Environment;

它与4.0.1.RELEASE完美配合.

我的pom.xml:

<properties>
    <java-version>1.8</java-version>
    <org.springframework-version>5.0.6.RELEASE</org.springframework-version>
    <org.aspectj-version>1.6.10</org.aspectj-version>
    <org.slf4j-version>1.6.6</org.slf4j-version>
</properties>

<dependencies>
    <!-- Spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
        <exclusions>
            <!-- Exclude Commons Logging in favor of SLF4j -->
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <!-- Joda TIme dependency for date and time -->
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.3</version>
    </dependency>

    <!-- Spring security -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency>

    <dependency> …
Run Code Online (Sandbox Code Playgroud)

java spring

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

在注释注入中使用ReloadableResourceBundleMessageSource

ReloadableResourceBundleMessageSource在我的web项目中使用,并且我将类注入到servlet中,问题是我想使用Spring注释注入类但它似乎不起作用?我的代码是:

my.xml

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>classpath:myList</value>
        </list>
    </property>
    <property name="cacheSeconds" value="1"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

myServletClass.java

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

ApplicationContext applicationContext = new ClassPathXmlApplicationContext("my.xml");
String message = applicationContext.getMessage(message, null, "Default 
", null);

}
Run Code Online (Sandbox Code Playgroud)

如何注入ReloadableResourceBundleMessageSource使用注释?

spring annotations servlets code-injection

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

spring自动装配有什么好处

自动装配是Spring的优势究竟是什么?

春季自动装配的一个例子是

public class TestClass {
    testMethod() {
        // .....
    };
}

public class MainClass {
    public static void main(String[] args) {
        ApplicationContext ctx = new ClasspathXmlApplicationContext("test.xml");
        TestMethod obj = (TestClass) ctx.getBean("test");
        obj.testMethod();
    }
}
Run Code Online (Sandbox Code Playgroud)

测试文件

<bean id="test" class="TestClass">
Run Code Online (Sandbox Code Playgroud)

可以使用以下方法完成正常操作中的相同操作:

public class MainClass {
    public static void main(String[] args) {
        TestClass obj = new TestClass();
        obj.testMethod();
    } 
}
Run Code Online (Sandbox Code Playgroud)

Spring 的优势是什么,我的意思是我听说过控制反转和依赖注入这两个术语。在这两个示例中,通过newoerator再次通过 Spring XML 使用了一次 TestClass 引用。那么有人可以用简单的术语解释什么是优势。

spring dependency-injection inversion-of-control autowired

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

RequireJS + Waypoints:Object [object Object]没有方法'waypoint'

尽管一切看起来都不错,但我无法使用带有RequireJS的航路点.这是我的代码:http://jsfiddle.net/7nGzj/

main.js

requirejs.config({
    "baseUrl": "theme/PereOlive/js/lib",
    "paths": {
      "app":"../app",
      "jquery": "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min"
    },
    "shim": {
        "waypoints.min": ["jquery"]
    }
});
requirejs(["app/common"]);
Run Code Online (Sandbox Code Playgroud)

common.js

define([
    'jquery',
    "waypoints.min",
], function () {
    $(function () {
        console.log($.waypoints);
        $('#loading').waypoint(function (direction) {
            // do stuff
        });
    });
});
Run Code Online (Sandbox Code Playgroud)

我甚至说它确保jQuery正确加载但它不起作用.我的其他库就像它们应该的那样(responsiveslides,flexslider,hoverintent,smoothscroll,..).

  • jQuery V1.10.2
  • 航点V2.0.3
  • RequireJS V2.1.8

jquery requirejs jquery-waypoints

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

Spring只是渲染一个html页面

问题:

使用Spring 4,我在访问网页时得到了这个

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Aug 15 16:41:29 BST 2014
There was an unexpected error (type=Not Found, status=404).
Run Code Online (Sandbox Code Playgroud)

是)我有的:

我有这个Main类:

// src/main/java/abc/Main.java
package abc;

import abc.web.WebAppConfig;
import org.springframework.boot.SpringApplication;

public class Main {
    public static void main(String[] args) {
        SpringApplication.run(WebAppConfig.class);

    }
}
Run Code Online (Sandbox Code Playgroud)

然后我有这个WebAppConfig.class(目前只有一些配置注释):

// src/main/java/abc/web/WebAppConfig.java
package abc.web;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan
@EnableAutoConfiguration
public class WebAppConfig {

}
Run Code Online (Sandbox Code Playgroud)

而这个控制器HomeController.java:

// src/main/java/abc/web/HomeController.java
package abc.web; …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc spring-boot

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

如何在电子邮件主题行中添加 HTML 效果?

我正在使用 Apache Commons Email API 从我的应用程序发送电子邮件。我无法获得已发送电子邮件的正确主题行。例如,有问题的主题行:“ This is my email Subject line companyName<sup>\xc2\xae</sup>”。我预计主题是“I want something likewise - companyName\xc2\xae ”,但上标效果没有显示。

\n

email html-email

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

Spring 在方法上的 @Profile 是一个好的实践吗

我有一个公开休息服务的 Spring Boot Web 应用程序。

我问自己如何正确管理过滤器上的配置文件。实际上,我的应用程序有 2 个配置文件:dev 和 prod(你猜它代表什么......)

在产品模式下,我比开发模式下有更多的过滤器需要激活。

我的过滤器配置类如下:

@Configuration
public class FiltersConfig {

    @Bean
    public FilterRegistrationBean filterRegistrationBean(CompositeFilter compositeFilter){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setFilter(compositeFilter);
        return filterRegistrationBean;
    }

    @Bean
    @Profile("dev")
    public CompositeFilter devCompositeFilter(){
        CompositeFilter compositeFilter = new CompositeFilter();
        List<Filter> filtersList = new ArrayList<>();
        //filtersList.add(filter1());
        compositeFilter.setFilters(filtersList);
        return compositeFilter;
    }


    @Bean
    @Profile("prod")
    public CompositeFilter prodCompositeFilter(){
        CompositeFilter compositeFilter = new CompositeFilter();
        List<Filter> filtersList = new ArrayList<>();
        //filtersList.add(filter1());
        compositeFilter.setFilters(filtersList);
        return compositeFilter;
    }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  • 在方法上添加 @Profile 是一个好习惯吗?
  • 有没有一种方法可以强制编译器排除使用与当前设置不同的配置文件注释的类、方法等?(我不希望我的生产 jar/war …

java spring maven spring-profiles spring-boot

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

Mockito在使用@Mock时将Null值注入Spring bean?

由于我是Spring Test MVC的新手,我不明白这个问题.我从http://markchensblog.blogspot.in/search/label/Spring中获取了以下代码

变量mockproductService不是从Application Context注入的,它null在使用@Mock注释和获取assetion错误时包含值.

我目前遇到的断言错误如下:

java.lang.AssertionError: Model attribute 'Products' expected:<[com.pointel.spring.test.Product@e1b42, com.pointel.spring.test.Product@e1f03]> but was:<[]>
    at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:60)
    at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:89)
    at org.springframework.test.web.servlet.result.ModelResultMatchers$2.match(ModelResultMatchers.java:68)
    at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:141)
    at com.pointel.spring.test.ProductControllerTest.testMethod(ProductControllerTest.java:84)
Run Code Online (Sandbox Code Playgroud)

注意:如果我使用@Autowired而不是@Mock它工作正常.

测试控制器类

RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations={"classpath:mvc-dispatcher-servlet.xml"})
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class})
public class ProductControllerTest {

    @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

   @InjectMocks
    private ProductController productController;

    @Mock
    //@Autowired
    private ProductService mockproductService;


    @Before
    public void setup() {

    MockitoAnnotations.initMocks(this);

    List<Product> products = new ArrayList<Product>();
    Product product1 = new Product();
    product1.setId(new …
Run Code Online (Sandbox Code Playgroud)

java spring unit-testing mockito

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

这段Tiled C++代码有什么作用?

我试图从Tiled实用程序的地图格式文档中找出这段代码的目的.

const int gid = data[i] |
                data[i + 1] << 8 |
                data[i + 2] << 16 |
                data[i + 3] << 24;
Run Code Online (Sandbox Code Playgroud)

看起来有一些"or-ing"和位移,但我不知道这是什么目的,在使用平铺程序的数据的情况下.

c c++ tiling

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