小编Kev*_*vin的帖子

ASP.NET学习路径

我想向有经验的ASP.NET开发人员询问如何攀登ASP.NET的学习曲线.

我是一位经验丰富的C++和C#开发人员,没有Web应用程序经验.

我发现ASP.NET MVC和ASP.NET是两种不同的技术.我只想问:

  1. 这两种技术是否会共存或MVC将取代ASP.NET?
  2. 如果我想学习ASP.NET MVC.我是否需要学习ASP.NET作为先决条件?
  3. 你能推荐一些学习资源吗?书?视频?没有支付微软培训:(

非常感谢

c# asp.net asp.net-mvc-3

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

编写具有大量可选属性的 java 对象的最佳方法

我必须编写一个用于保存计算结果的 Java 对象。结果包含大量字段,根据所使用的算法类型,可能会或可能不会设置这些字段。例如:

class EquityValuationResult {
    private ValuationAlgorithm algorithm;
    private int yield;
    private double curve;
    private double meanValue;
    private double probability;
    private int standardDeviation;
    private boolean approximateValue;
    ......
    //Getter and Setters

}
Run Code Online (Sandbox Code Playgroud)

对于不同的 ValuationAlgorithm,这些属性的内容可能不同。例如,如果算法是A,yield 和probability 会包含计算值,其余的将为null;如果算法是 B,standardDeviation 和 curve 将包含结果,其余的将为 null 等。规则非常复杂,例如,如果 approcimateValue 为 true,则某些值将被覆盖等。因此,所有这些属性必须在一个类中,因为它们在逻辑上是一个结果。

另一种方法是使用 Map

class EquityValuationResult {
    private final String YIELD = "yield";
    private final String CURVE = "curve";
    ........

    private ValuationAlgorithm algorithm;
    private final Map<String, Object> result = new HashMap<String, Object>();

    // Getter and Setters …
Run Code Online (Sandbox Code Playgroud)

java pojo

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

Maven项目无法在本地存储库中找到依赖项

我有一个maven项目设置.

在我的maven POM文件中,它定义如下:

<?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>

    <parent>
        <groupId>com.myProject</groupId>
        <artifactId>basePOM</artifactId>
        <version>1.0</version>
        <relativePath>../../../shared/common/pom.xml</relativePath>
    </parent>

    <groupId>com.myProject.services</groupId>
    <artifactId>orderservice</artifactId>
    <version>developer</version>
    <packaging>war</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!--Internal dependencies-->
        <dependency>
            <groupId>com.myProject.shared</groupId>
            <artifactId>model</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-spring</artifactId>
        </dependency>
    </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

我有一个父POM定义了一些常见的位:

<?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>

    <name>Base POM</name>
    <groupId>com.myProject</groupId>
    <artifactId>basePOM</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.myProject.shared</groupId>
                <artifactId>model</artifactId>
                <version>developer</version>
            </dependency>

            <dependency>
                <groupId>org.jboss.resteasy</groupId>
                <artifactId>resteasy-jaxrs</artifactId>
                <version>1.2.GA</version>
                <exclusions>
                    <exclusion> …
Run Code Online (Sandbox Code Playgroud)

java maven-2

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

不能在Java中使用Scala类

我相信Scala和Java可以使用彼此的类.

但是,我发现自己的情况是我的Java类不能在同一个包中使用Scala类.

scala类定义为:

class CustomerService extends AbstractCustomerService {
Run Code Online (Sandbox Code Playgroud)

试图使用这段代码的代码是:

public Deployer() {
        singletons.add(new CustomerService());
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3:compile (default-compile) on project orderservice: Compilation failure
[ERROR] \devel\raven\services\orderservice\service\src\main\scala\com\mxyy\orderservice\customer\Deployer.java:[12,31] cannot find symbol
[ERROR] symbol  : class CustomerService
[ERROR] location: class com.mxyy.orderservice.customer.Deployer
Run Code Online (Sandbox Code Playgroud)

有人可以给我一些暗示吗?

非常感谢

java scala maven scala-java-interop

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

WeakReference to String和String常量

我从维基百科看到了关于弱引用的这个例子:

import java.lang.ref.WeakReference;

public class ReferenceTest {
        public static void main(String[] args) throws InterruptedException {

            WeakReference r = new WeakReference(new String("I'm here"));
            WeakReference sr = new WeakReference("I'm here");
            System.out.println("before gc: r=" + r.get() + ", static=" + sr.get());
            System.gc();
            Thread.sleep(100);

            // only r.get() becomes null
            System.out.println("after gc: r=" + r.get() + ", static=" + sr.get());

        }
}
Run Code Online (Sandbox Code Playgroud)

我不明白在这种情况下为什么只有r.get()返回null而不是sr.get().有人能让我知道原因吗?

非常感谢.

java weak-references

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

如何配置Apache2重定向URL

我正在尝试在Apache中配置url重定向.我尝试了一些方法,没有任何作用.有人可以告诉我解决方案,因为它似乎并不太难.

我将重定向来自:

https://myhost/configuration/jmx-console
Run Code Online (Sandbox Code Playgroud)

至:

http://myanohterhost/jmx-console
Run Code Online (Sandbox Code Playgroud)

这是一个https到http重定向.

有人能指出我正确的方向吗?

非常感谢!

redirect apache2

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

使用Scala查找素数.帮助我改进

我写了这段代码,以便在scala中找到小于给定数字i的素数.

def findPrime(i : Int) : List[Int] = i match {
    case 2 => List(2)
    case _ => {
    val primeList = findPrime(i-1)
    if(isPrime(i, primeList)) i :: primeList else primeList
    }
}

def isPrime(num : Int, prePrimes : List[Int]) : Boolean = prePrimes.forall(num % _ != 0)    
Run Code Online (Sandbox Code Playgroud)

但是,我感觉findPrime函数,特别是这部分:

case _ => {
    val primeList = findPrime(i-1)
    if(isPrime(i, primeList)) i :: primeList else primeList
}
Run Code Online (Sandbox Code Playgroud)

不是功能风格.

我还在学习函数式编程.任何人都可以帮我改进这个代码,使其更具功能性.

非常感谢.

algorithm primes functional-programming scala

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

Guice:后期绑定怎么做?

我正在尝试使用 Google Guice 进行一些后期绑定。

public class MyClassProvider implements Provider<MyClass>{
    private DependencyClass dep;
    private WebService webservice;

    @Inject
    MyClassProvider(DependencyClass dep, WebService webservice){
        this.dep = dep;
        this.webservice = webservice;
    }

    public MyClass get() {
        MyClass myclass = webservice.call(dep);
    }
}
Run Code Online (Sandbox Code Playgroud)

我在模块中有一个绑定:

   bind(MyClass.class).toProvider(MyClassProvider.class).in(ServletScopes.REQUEST);
Run Code Online (Sandbox Code Playgroud)

我有另一个类 ConsumerClass,它需要使用 MyClass。问题来了,因为dep在某个点之前将为null,我将无法将MyClass注入ConsumerClass,因此我注入了Provider。

public class ConsumerClass {
    private MyClassProvider myClassProvider;

    @Inject
    public ConsumerClass(Provider<MyClass> myClassProvider){
       this.myClassProvider = myClassProvider;
    }

    ......

    public void myfunction() {
        // Here dep is initialized and become non-null here.

        // Then, I call
        MyClass myClass = myClassProvider.get();

    } …
Run Code Online (Sandbox Code Playgroud)

java guice

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

如何在 Guava Optional 中保存空值

我是番石榴图书馆的新手。

我试图在我的方法参数中使用 Optional 。我发现的一个问题是我不可能将空值传递给 Optional。

我认为引入Optional的目的是为了区分

  1. 没有价值的东西
  2. 具有空值的东西

例如,Optional.absent() 表示该值不存在。而 null 是一个存在的值。

有了这个逻辑,我假设 Optional 必须有某种方式允许我们在其中保存空值。但是,我找不到办法做到这一点。

我的方法定义为:

void myMethod(Optional<String> arguments) {
    ....
}
Run Code Online (Sandbox Code Playgroud)

如果我使用

myMethod(Optional.of(null));
Run Code Online (Sandbox Code Playgroud)

它会给我运行时错误说值不能为空。

我怎么可能在 Optional 中传递 null ?

java guava

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

不同类型的 Cron 表达式

我对unix系统中使用的Cron表达式和使用Java Quartz的一个有点困惑。

Unix 使用的标准 cron 表达式的最左边条目代表“分钟”。但是 Quartz 使用的 cron 表达式使用最左边的条目来表示“第二”:

http://quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger

我想知道目前正在使用多少个版本的 cron 表达式?

如果我将标准版本的 cron 传递到 Quartz 中会发生什么?

多谢

java cron quartz-scheduler

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