我在SpringToolSuite中有一个动态Web项目.它被转换为Maven项目.
我遇到了这个问题:
Mising artifact org.springframework:spring.jar:4.2.6
我已经尝试过清理,重建和运行项目.它给:
读取文件C时出错:\ Users\jublikon.m2\repository\org\springframework\spring\4.2.6\spring-4.2.6.jar C:\ Users\jublikon.m2\repository\org\springframework\spring\4.2. 6\spring-4.2.6.jar(系统找不到指定的文件)
我不明白为什么我在使用Maven时要求jar文件?
的pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>HelloWeb</groupId>
<artifactId>HelloWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>C:\Users\name\Development\Spring\Projects\HelloWeb\src\main\java</sourceDirectory>
<scriptSourceDirectory>C:\Users\name\Development\Spring\Projects\HelloWeb\src\main\scripts</scriptSourceDirectory> …Run Code Online (Sandbox Code Playgroud) 问题:我正在使用maven并突然遇到一些错误:
For artifact {org.springframework.boot:spring-boot-starter-data-jpa:null:jar}: The version cannot be empty. (org.apache.maven.plugins:maven-resources-plugin:2.6:resources:default-resources:process-resources)
org.apache.maven.artifact.InvalidArtifactRTException: For artifact {org.springframework.boot:spring-boot-starter-data-jpa:null:jar}: The version cannot be empty.
at org.apache.maven.artifact.DefaultArtifact.validateIdentity(DefaultArtifact.java:148)
at org.apache.maven.artifact.DefaultArtifact.<init>(DefaultArtifact.java:123)
at org.apache.maven.artifact.factory.DefaultArtifactFactory.createArtifact(DefaultArtifactFactory.java:157)
at org.apache.maven.artifact.factory.DefaultArtifactFactory.createDependencyArtifact(DefaultArtifactFactory.java:57)
at org.apache.maven.project.artifact.MavenMetadataSource.createDependencyArtifact(MavenMetadataSource.java:328)
at org.apache.maven.project.artifact.MavenMetadataSource.createArtifacts(MavenMetadataSource.java:503)
at org.apache.maven.lifecycle.internal.DefaultProjectArtifactFactory.createArtifacts(DefaultProjectArtifactFactory.java:50)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:119)
at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:245)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:330)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360)
at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:172)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:115)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:105)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86)
at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) …Run Code Online (Sandbox Code Playgroud) 我想以编程方式在ViewPager中制作一张幻灯片。
我的问题是,滑动事件是由放置在ViewPager所保存片段中的按钮调用的。
我知道代码:
viewpager.setCurrentItem(int index)
Run Code Online (Sandbox Code Playgroud)
现在,我的想法是使ViewPager变量成为公共静态变量,以从子片段访问它。但是不能从子片段访问静态变量。
如何通过单击页面内的按钮来实现幻灯片制作?
问题:我有一个RecyclerView和Toolbar一个CoordinatorLayout.在RecyclerView低于Toolbar但它不应该.
问题:我怎样才能实现RecyclerView和Toolbar拥有一个边界?
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
<include
android:id="@+id/toolbar_main"
layout="@layout/toolbar"></include>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/maschinelistcontainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
maschine_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbars="vertical" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) xml android toolbar android-recyclerview android-coordinatorlayout
我有一个ViewPager我想添加片段的。ViewPager 可以在屏幕上正确查看,但不幸的是它不包含任何内容。
我在一些帖子中看到了替换的建议
getSupportFragmentManager()
Run Code Online (Sandbox Code Playgroud)
和
getChildFragmentManager()
Run Code Online (Sandbox Code Playgroud)
但我需要ActionBar. 不幸的ChildFragmentmanager是,在AppCompatActivity.
在调试时,我意识到 Fragment 的onCreateView()方法被调用并返回一个布局。
问题:我怎样才能使Fragments可见?是我的代码与该示例的主要区别什么?
活动:
public class ViewPagerActivity extends AppCompatActivity {
private ViewPager mViewPager;
private List<Location> locationList = new ArrayList<>();
private locationsBaseHandler db;
private CustomPagerAdapter mAdapter;
private Location mLocation;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_viewpager);
locationList.add(someData);
mViewPager = (ViewPager) findViewById(R.id.viewpager);
mAdapter = new CustomPagerAdapter(this, getSupportFragmentManager(), locationList);
mViewPager.setAdapter(mAdapter);
}
}
Run Code Online (Sandbox Code Playgroud)
寻呼机适配器:
public class …Run Code Online (Sandbox Code Playgroud) 我有一个collapsingToolbarLayout,我需要对 title 做一些额外的设置TextView。
问题:如何获得对该 TextView 的引用?
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/review_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.stack.overflow.reviewmaschine.ReviewMaschineActivity"
tools:ignore="MergeRootFrame">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar">
<android.support.v7.widget.Toolbar
android:id="@+id/detail_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior = "@string/appbar_scrolling_view_behavior"
/>
<com.mego.smscloud.reviewmaschine.SaveFloatingActionButton
android:id="@+id/review_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:backgroundTint="@color/colorPrimary"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_floppy_white_48dp"
app:borderWidth="0dp"
app:elevation="@dimen/fab_elevation"
app:rippleColor="#00ffff"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
编辑:
简单地将 a 添加TextView到 theToolbar并不能将其集成到与CollapsingToolbarLayouttitle相同的行为中

我有一个tree由数据结构表示:
data Tree a = Node (Tree a) (Tree a)| Leaf a
t1 :: Tree Int
t1 = (Node (Node (Leaf 23) (Leaf 42)) (Node (Leaf 19) (Leaf 65)))
Run Code Online (Sandbox Code Playgroud)
现在我需要打印叶子的数据:
toList :: Tree a -> [a]
toList (Node (Leaf a) (Leaf b)) = [a] ++ [b]
toList (Node (Leaf a) (Node x y)) = [a] ++ (toList (Node x y))
toList (Node (Node x y) (Leaf b)) = (toList (Node x y)) ++ [b]
Run Code Online (Sandbox Code Playgroud)
不幸的是,我一直收到错误:
函数toList中的非穷举模式
但是我使用括号.
我做错了什么?
我只是想扩展ImageView:
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
public class SquareImageView extends ImageView {
public SquareImageView(Context context) {
super(context);
}
public SquareImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = getMeasuredWidth();
setMeasuredDimension(width, width);
}
}
Run Code Online (Sandbox Code Playgroud)
但是Android Studio会返回编译错误:
此自定义视图应该扩展android.support.v7.widget.AppCompatImageView
但导入android.support.v7.widget.AppCompatImageViewinsted android.widget.ImageView并不能解决问题,因为ImageView被标记为未导入...
我在这做错了什么?
当我将屏幕方向从垂直更改为水平然后再次返回时,RecyclerView 会重新绘制并覆盖旧的(您可以在卡片视图之间看到它):
问题:如何抑制这种行为,以便 Android 始终重用最初创建的 RecyclerView?
XML 片段
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:lib="http://schemas.android.com/tools"
android:id="@+id/maschine_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/maschine_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
主要XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/maschineCoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
<include
android:id="@+id/toolbar_main"
layout="@layout/toolbar"></include>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/machinelistcontainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior = "@string/appbar_scrolling_view_behavior"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_cloud_sync_maschinen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:backgroundTint="@color/colorPrimary"
android:src="@drawable/ic_cloud_sync_white_48dp"
app:borderWidth="0dp"
app:elevation="@dimen/fab_elevation"
app:rippleColor="#00ffff"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud) 我有两节课A和B。
问题:为什么该行System.out.println(b.x)结果打印 23?
我同意结果为 22,因为 的构造函数A和 每个构造函数都会将 1B递增static int y。
public class A {
public long x = 0;
public static int y = 20;
public A(float x) {
this((int) x );
A.y++;
}
public A(int x) {
this.x = x;
}
public int f(double d) {
return 1;
}
public int f(long l) {
return 2;
}
}
public class B extends A {
public int …Run Code Online (Sandbox Code Playgroud)