Eclipse初次java开发问题总结-4-Maven使用问题汇总

Eclipse初次java开发问题总结-4-Maven使用问题汇总

Non-resolvable parent POM

[INFO] Scanning for projects...

[ERROR] The build could not read 1 project -> [Help 1]

[ERROR]  

[ERROR]   The project com.iflytek.ossp:ossp-resserver-service:1.0.0-SNAPSHOT (C:\Users\moon\Desktop\ossp-resservice-maven\ossp-resserver-service\pom.xml) has 1 error

[ERROR]     Non-resolvable parent POM: Could not find artifact com.iflytek.ossp:ossp-resserver-all:pom:1.0.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 11, column 10 -> [Help 2]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

无法解析父级的POM文件,应该是是POM文件中使用了继承。

<parent>

        <groupId>com.iflytek.ossp</groupId>

        <artifactId>ossp-resserver-all</artifactId>

        <version>1.0.0-SNAPSHOT</version>

</parent>

可以尝试加入<relativePath>

<parent>

        <groupId>com.iflytek.ossp</groupId>

        <artifactId>ossp-resserver-all</artifactId>

        <version>1.0.0-SNAPSHOT</version>

        <relativePath>../ossp-resserver-all/pom.xml</relativePath>

</parent>

Unable to locate the Javac Compiler in

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ossp-resserver-service: Compilation failure

[ERROR] Unable to locate the Javac Compiler in:

[ERROR] C:\Java\jre6\..\lib\tools.jar

[ERROR] Please ensure you are using JDK 1.4 or above and

[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).

[ERROR] In most cases you can change the location of your Java

[ERROR] installation by setting the JAVA_HOME environment variable.

[ERROR] -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

出现类似的错误应该是Jre配置问题:

右击项目->Java Buid Path->Libraries->JRE->Edit->Install JREs...->Edit->JRE system libraries->Add External JREs..->找到缺少的jar(toos.jar)添加进去。

No goals have been specified for this build.

Maven Buid时出现下面这个错误:

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

是因为没有指定buid goal,在POM文件中的buid节中加入默认值就行了。

<defaultGoal>compile</defaultGoal>

将第三方jar包发布到私服

1、首先要修改eclipse中的Maven配置。

不要使用内嵌的默认配置。

指向Maven的安装目录。

2、配置Maven的setting.xml

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <pluginGroups>

  </pluginGroups>

  <proxies>

  </proxies>

  <servers>

    <server>

      <id>nexus-releases</id>

      <username>admin</username>

      <password>123</password>

    </server>

    <server>

      <id>nexus-snapshots</id>

      <username>admin</username>

      <password>123</password>

    </server>

  </servers>

  <mirrors>

  </mirrors>

  <profiles>

    <profile>

      <id>dev</id>

      <repositories>

        <repository>

          <id>local-nexus</id>

          <url>http://192.168.77.214:9088/nexus/content/groups/public/</url>

          <releases>

            <enabled>true</enabled>

          </releases>

          <snapshots>

            <enabled>true</enabled>

          </snapshots>

        </repository>

      </repositories>

    </profile>

  </profiles>

  <activeProfiles>

    <activeProfile>dev</activeProfile>

  </activeProfiles>

</settings>

3、发布第三方jar包

 

第二篇:Java总结

Java总结

Java语言不允许程序员直接控制内存空间的使用。

内存空间的分配和回收是有jre 负责在后台自动进行,尤其是无用内存空间的回收操作。 垃圾回收器不可以被强制执行,但程序员可以通过调用system.gc()方法来建议执行垃圾回收器。只是建议!

完全彻底的根绝内存渗漏体的产生是不可能的

引用变量法来暗示回收机制来回收!

开发Java应用程序的基本步骤:

1、编写源代码;2、编译源代码;3、运行程序。

一个Java源文件中至多只能有一个public 的 class ,但可以有多个 class的定义; 源文件名必须和程序中定义 的 public 的 类名相同;

Main()方法是Java应用程序的入口方法。

类和对象是面向对象编程思想中的核心和基础。

产生对象的过程称为“实例化”。

类是用来描述一组具有相同特征对象的应包括的数据、行为特征。

因此类有属性(数据/状态)和方法(行为/操作)。

类的定义中所包含的数据称为属性,也称为全局变量。

属性名称的首字母一般采取小写字母。

Java语言中 类、方法以及属性声明的次序并无严格要求。

构造器不能有返回类型声明,它的方法名必须与类名完全一致;

如果程序中没有定义任何的构造器,则编译器将会自动加上一个不带任何参数的构造器; 如果在程序中定义了构造器,则编译器将不再提供默认的构造器。(实例化时应注意)

Package 0个或1个 放在文件开头 为避免类名的重复

Import 0个或多个 必须放在类定义之前 package之后(如果存在)

Public 的类只能有一个

其他的类可以有多个

在Java类文件中,使用“.”来分割报的层次。

编译时用“\”指明文件路径

执行时用“.”指明包名称

Java注释

单行注释: //

多行注释: /* */

文档注释: javadoc注释 /** */

Javadoc注释:包含在这部分里的注释可以通过javadoc命令来自动生成API文档;

Javadoc 只处理源文件在类/接口、 方法、域、构造器之前的注释,忽略其他地方的注释。

分隔符

一条语句是以分号结尾的一行代码

一个语句块是以一对花括号为边界的语句的集合

Java 中允许有任意多的空格,包括换行;

标识符

用作给变量、类和方法命名

以字母、下划线和“$”符开头

首字符外可以跟字母、下划线、和“$”或数字;

Java是一门强类型的语言。所有的变量都必须显示声明类型。

Java数据类型: 原始类型(简单类型) 和 引用类型

简单类型:

Boolean byte int float char short long double 一字节 四字节 四字节 两字节 八字节 八字节

算术运算符: + - * / 分别为加、减、乘、除。、

递增递减运算符: n++、++n、n--、--n.

关系和布尔运算符: >、<、>=、<=、!=

布尔运算符:!、&、|、&&、||

三元运算符:conditions?a:b;

字符串连接运算符:+;

Break是强行终止循环语句,而continue是略过循环中的剩下的语句,重新开始新的循环

数组的初始化

在成功创建一个数组后,它将完成如下三个动作:

1、 创建一个数组对象;

2、 在内存中给数组分配存储空间

3、 给数组的元素初始化一个相应的数据类型的默认值。

冒泡排序----交换排序的一种

方法:相邻两元素进行比较,如有需要则进行交换,每完成一次循环就将最大元素排 在最后(如从小到大排序),下一次循环是将其他的数进行类似操作。

Arrays对象中的方法 java.util包中的类

Java中, 一个类只能从一个父类中继承 即单继承

Java.lang 包中的object类是所有类的顶级父类;

Private : 同一个类中可以引用 限制最严格的一个修饰符

Default : 同一个类 同一个包中能引用

Protected: 同一个类 同一个包中 子类中 能引用

Public : 同一个类 同一个包 子类 全局 都能引用

一般,将和其他类无关的属性或方法设置成 private

需要将它给其他的类访问的属性或方法才将它设置成 public 或 protected ; 或者不加任何修饰,将它设置成default ;

Default 不是关键字,它只是表明了一种访问限制状态。

方法的覆盖(重写):

在子类中定义某方法与其父类有相同的名称和参数,我们说该方法被重写 (Overriding)。子类的对象使用这个方法时,将调用子类中的定义,对它而言,父类中的定义如同被"屏蔽"了。

方法的重载:

多个同名函数同时存在,具有不同的参数个数/类型。

在类中可以创建多个方法,它们具有相同的名字,但具有不同的参数和不同的定义。调用方法时通过传递给它们的不同参数个数和参数类型来决定具体使用哪个方法, 这就是多态性。

注意:

重载的时候,方法名要一样,但是参数类型和个数不一样,返回值类型可以相同也可以不相同。无法以返回型别作为重载函数的区分标准。

相关推荐